[boost] [tuple] - Move constructors for Tuple

26 views
Skip to first unread message

Moore, Andrew

unread,
Feb 5, 2013, 5:49:33 PM2/5/13
to bo...@lists.boost.org
Are there plans for move constructors/assignment operations in the tuples library?

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Vicente J. Botet Escriba

unread,
Feb 6, 2013, 1:10:26 PM2/6/13
to bo...@lists.boost.org
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

Adam Wulkiewicz

unread,
Feb 21, 2013, 7:03:43 PM2/21/13
to bo...@lists.boost.org
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

paul Fultz

unread,
Feb 21, 2013, 10:37:06 PM2/21/13
to bo...@lists.boost.org


> 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

Adam Wulkiewicz

unread,
Feb 22, 2013, 7:51:58 AM2/22/13
to bo...@lists.boost.org
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

unread,
Feb 22, 2013, 8:01:00 AM2/22/13
to bo...@lists.boost.org
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_move.cpp

paul Fultz

unread,
Feb 22, 2013, 10:27:51 AM2/22/13
to bo...@lists.boost.org


>> 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

Adam Wulkiewicz

unread,
Feb 22, 2013, 2:32:17 PM2/22/13
to bo...@lists.boost.org
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

unread,
Feb 22, 2013, 9:00:12 PM2/22/13
to bo...@lists.boost.org
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.
Reply all
Reply to author
Forward
0 new messages