我知道Visual Studio 2010的标准库已经被重写以支持右值引用,这大大提高了它的性能。
gcc 4.4(及更高版本)的标准库实现是否支持右值引用?
答案 0 :(得分:4)
我是从gcc 4.4的STL中找到的:
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_Vector_base(_Vector_base&& __x)
: _M_impl(__x._M_get_Tp_allocator())
{
this->_M_impl._M_start = __x._M_impl._M_start;
this->_M_impl._M_finish = __x._M_impl._M_finish;
this->_M_impl._M_end_of_storage = __x._M_impl._M_end_of_storage;
__x._M_impl._M_start = 0;
__x._M_impl._M_finish = 0;
__x._M_impl._M_end_of_storage = 0;
}
#endif
答案 1 :(得分:1)
GCC supports rvalue references。不幸的是,the libstc++ page没有说明库实现是否利用了这一点。