Opened 10 years ago
Last modified 10 years ago
#7276 new Feature Requests
Add move semantics
| Reported by: | viboes | Owned by: | Joel de Guzman |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | tuple |
| Version: | Boost 1.51.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
Boost.Tuple lack move semantics for its arguments. It should be great if it can comply with the c++11 standard when the compiler provides rvalue references and use Boost.Move otherwise.
Note:
See TracTickets
for help on using tickets.

I've created experimental version of tuple supporting move-semantics here:
http://svn.boost.org/svn/boost/sandbox/tuple-move/
To ensure backward compatibility I've defined copy assignment explicitly. It's possible to use tuples wrapped in classes with implicit assignment operator in c++03:
struct wrapper { tuple<int> t; }; /*...*/ wrapper w; w = wrapper();however in c++03 move assignment won't be used if tuple is returned from a function by value.
tuple<int> ret_tup(int a) { return tuple<int>(a); } /*...*/ tuple<int> t; t = ret_tup(0); // copy in c++03We could add a define check that disables mentioned explicit copy assignments. Defining it would enable moving of objects returned by value but prevent compilation of wrappers with implicit copy assignment.