VS2010 swap()操作引起的问题
来源:互联网 发布:无法连接到一个windows 编辑:程序博客网 时间:2024/05/26 19:14
最近遇到一个VS2010的问题。
debug跟到代码里,才注意到有这个_Move() 之类的函数。
我遇到的问题是由于map::swap()引起的。
之前vs2005可以支持swap发生在不同的allocator下,现在会产生问题,估计是为了支持"右值引用"导致的。
虽然从vs2010的代码看起来,应该是继续提供支持的,放点代码过来:
void swap(_Myt& _Right)
{ // exchange contents with _Right
if (this == &_Right)
; // same object, do nothing
else if (get_allocator() == _Right.get_allocator())
{ // same allocator, swap control information
this->_Swap_all(_Right);
_Swap_adl(this->comp, _Right.comp);
_STD swap(this->_Myhead, _Right._Myhead);
_STD swap(this->_Mysize, _Right._Mysize);
}
else
{ // different allocator, do multiple assigns
_Myt _Tmp = _Move(*this);
*this = _Move(_Right);
_Right = _Move(_Tmp);
}
}
但是,由于这个_Move() 会间接调到_Assign_rv() 就会导致问题!
void _Assign_rv(_Myt&& _Right)
{ // assign by moving _Right
if (this == &_Right)
;
else if (get_allocator() != _Right.get_allocator())
_Xinvalid_argument("invalid map/set<T> move assign");
else
{ // clear this and steal from _Right
clear();
this->_Swap_all(_Right);
_Swap_adl(this->comp, _Right.comp);
_STD swap(this->_Myhead, _Right._Myhead);
_STD swap(this->_Mysize, _Right._Mysize);
}
}
- VS2010 swap()操作引起的问题
- swap()引起的指针思考
- 在VS2010进行MFC编程设置字符集的问题(使用多字节字符集引起错误)
- mysql误操作引起的问题
- 项目发布操作不当引起的问题
- 故障重现(内存篇2),JAVA内存不足导致频繁回收和swap引起的性能问题
- 一个操作符优先级顺序引起的问题
- 大IO操作引起ksearch性能波动的问题分析
- scanf()引起的问题
- size_t引起的问题
- BuildPath引起的问题
- fork引起的问题
- tcp_timestamps 引起的问题
- 硬件加速引起的问题
- __packed引起的问题
- samba引起的问题
- submit引起的问题
- session引起的问题
- 网游创业失败全攻略
- 使用Eclipse的代码追踪功能
- WordPress for BlackBerry
- IE8 与 VS2005(VS2008) 冲突导致 出现 internet explorer脚本错误
- Win7 蓝屏代码 & 全攻略
- VS2010 swap()操作引起的问题
- android存储空间的检测
- Silverlight 上传
- CREATE TABLESPACE命令详解(转)
- SQL Server 中as语句后加英文,标点符号等内容
- Gpu Progame Guide G89 (二) 如何优化你的应用程序
- IncrediBuild分布式编译的使用
- 浅谈C++的智能指针
- Nand ECC校验和纠错原理及2.6.27内核ECC代码分析