[tuple] - Move constructors for Tuple

Are there plans for move constructors/assignment operations in the tuples library?

Le 05/02/13 23:49, Moore, Andrew a écrit :
Are there plans for move constructors/assignment operations in the tuples library?
I don't know, but there is clearly a need for c++03 compilers using Boost.Move. See https://svn.boost.org/trac/boost/ticket/7276 I hope that someone will take care of it soon. Best, Vicente

Vicente J. Botet Escriba wrote:
Le 05/02/13 23:49, Moore, Andrew a écrit :
Are there plans for move constructors/assignment operations in the tuples library?
I don't know, but there is clearly a need for c++03 compilers using Boost.Move. See https://svn.boost.org/trac/boost/ticket/7276
I hope that someone will take care of it soon.
Hi, I've put an experimental version in http://svn.boost.org/svn/boost/sandbox/tuple-move/ It was tested on VS2010, gcc, gcc-c++98, gcc-c++11, clang, clang-c++98, clang-c++11. It would be nice if someone tested it on other compilers. The additional test is included. Everything is implemented in detail/tuple_basic.hpp so it's included if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) I didn't add any revision or copyright info yet because I didn't know which one should I add. If there is a need for this version of tuple, please verify it and merge to trunk or give me the permission. Regards, Adam Wulkiewicz

Hi,
I've put an experimental version in
http://svn.boost.org/svn/boost/sandbox/tuple-move/
It was tested on VS2010, gcc, gcc-c++98, gcc-c++11, clang, clang-c++98, clang-c++11. It would be nice if someone tested it on other compilers. The additional test is included.
Everything is implemented in detail/tuple_basic.hpp so it's included if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
I didn't add any revision or copyright info yet because I didn't know which one should I add.
If there is a need for this version of tuple, please verify it and merge to trunk or give me the permission.
Regards, Adam Wulkiewicz
Will something like this compile on C++03 compilers? struct foo { tuple<int> x; }; foo a, b; a = b; Otherwise, it should have an option to disable Boost.Move. Thanks, Paul

paul Fultz wrote:
Will something like this compile on C++03 compilers?
struct foo { tuple<int> x; };
foo a, b; a = b;
Otherwise, it should have an option to disable Boost.Move.
It compiles. Why do you think it might not? I only didn't test the performance of this move-enabled version. The option to disable it may be added even if everything compiles. Regards, Adam

Adam Wulkiewicz wrote:
paul Fultz wrote:
Will something like this compile on C++03 compilers?
struct foo { tuple<int> x; };
foo a, b; a = b;
Otherwise, it should have an option to disable Boost.Move.
It compiles. Why do you think it might not?
I only didn't test the performance of this move-enabled version. The option to disable it may be added even if everything compiles.
FYI, I've not only added move ctors to tuples but also move assignments and they not only work with tuples but also may take tuples::cons or std::pair. If the compiler don't support rval references the std::pair is copied. tuples::cons is also fully move-enbled. Check out the test: https://svn.boost.org/svn/boost/sandbox/tuple-move/libs/tuple/test/tuple_mov... Regards, Adam

Will something like this compile on C++03 compilers?
struct foo { tuple<int> x; };
foo a, b; a = b;
Otherwise, it should have an option to disable Boost.Move.
Im sorry, it should be something like this: struct foo { tuple<int> x; }; foo a; a = foo();
It compiles. Why do you think it might not?
Because of this issue here: https://svn.boost.org/trac/boost/ticket/6167 Thanks, Paul

paul Fultz wrote:
Im sorry, it should be something like this:
struct foo { tuple<int> x; };
foo a; a = foo();
...
Because of this issue here: https://svn.boost.org/trac/boost/ticket/6167
It compiles now, thanks. Checked on clang (98, 11), gcc (98, 11), mingw, vs2010, for tuples and tuple::cons. - in c++98 copy assignment is called - in c++11 move assignment is called - in vc2010 copy assignment is called, it probably just doesn't generate implicit move assignment for foo. Btw, I saw the ticket. Everything that needs to be done is adding explicitly defined copy assignment taking const ref if BOOST_NO_CXX11_RVALUE_REFERENCES. Boost.Move BOOST_COPYABLE_AND_MOVABLE() macro adds only non-const ref version. If the const version was added as well it would probably fix all issues described in the ticket. Is there a reason why this isn't there? Regards, Adam

Adam Wulkiewicz wrote:
paul Fultz wrote:
Im sorry, it should be something like this:
struct foo { tuple<int> x; };
foo a; a = foo();
...
Because of this issue here: https://svn.boost.org/trac/boost/ticket/6167
It compiles now, thanks. Checked on clang (98, 11), gcc (98, 11), mingw, vs2010, for tuples and tuple::cons.
- in c++98 copy assignment is called - in c++11 move assignment is called - in vc2010 copy assignment is called, it probably just doesn't generate implicit move assignment for foo.
Btw, I saw the ticket. Everything that needs to be done is adding explicitly defined copy assignment taking const ref if BOOST_NO_CXX11_RVALUE_REFERENCES. Boost.Move BOOST_COPYABLE_AND_MOVABLE() macro adds only non-const ref version. If the const version was added as well it would probably fix all issues described in the ticket. Is there a reason why this isn't there?
And it now supports storing references also in c++11. Regards, Adam
participants (4)
-
Adam Wulkiewicz
-
Moore, Andrew
-
paul Fultz
-
Vicente J. Botet Escriba