问题描述
我正在尝试在代码中使用std::move
,但是我正在使用的编译器(g ++ 4.4)不支持它. boost::move
可以完全替代std::move
吗?谢谢.
I am trying to use std::move
in my codes, but the compiler (g++ 4.4) I am using does not support it. Can boost::move
substitute std::move
completely? Thanks.
推荐答案
std::move
(和启用了c ++ 0x支持的boost::move
)仅仅是从T&
到T&&
的转换.它实际上并没有移动任何东西.这意味着编译器必须支持指针T&&
的特定类型. GCC从4.3版本开始支持r值引用,因此boost版本应该没问题.
std::move
(and boost::move
when c++0x support is enabled) is just a cast from T&
to T&&
. It does not actually move anything. This means that the specific type of pointer T&&
must be supported by the compiler. GCC supports r-value references since version 4.3, so the boost version should be fine.
但是,为什么不能使用#include <utility>
中的std::move
?
However, is there a reason you can't use std::move
from #include <utility>
?
http://en.cppreference.com/w/cpp/utility/move
您只需要确保将-std=c++0x
指定为编译器选项即可启用gcc 4.4的有限c ++ 11支持.
You just need to make sure to specify -std=c++0x
as a compiler option in order to enable the limited c++11 support that gcc 4.4 has.
这篇关于对应于std :: move的boost库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!