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.

- 11,175
- 20
- 96
- 167
-
8`g++ 4.4` is very old. Consider moving to the newer version – alexeykuzmin0 Aug 04 '16 at 08:00
2 Answers
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.
However, is there a reason you can't use std::move
from #include <utility>
?
http://en.cppreference.com/w/cpp/utility/move
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.

- 936
- 14
- 19
-
4In C++03 `boost::move` it is **not just a cast**: that is why it works there. "Boost.Move is based on macros that are expanded to true rvalue references in C++0x compilers and emulated rvalue reference classes and conversion operators in C++03 compilers." See the [Boost docs](http://www.boost.org/doc/libs/1_59_0_b1/doc/html/move/how_the_library_works.html) – nugae Aug 04 '16 at 12:42
Yes it can
What is Boost.Move?
Rvalue references are a major C++0x feature, enabling move semantics for C++ values. However, we don't need C++0x compilers to take advantage of move semanatics. Boost.Move emulates C++0x move semantics in C++03 compilers and allows writing portable code that works optimally in C++03 and C++0x compilers.
Source: http://www.boost.org/doc/libs/1_59_0_b1/doc/html/move.html

- 9,266
- 5
- 45
- 98