This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

522. Tuple doesn't define swap

Section: 22.4 [tuple], 99 [tr.tuple] Status: CD1 Submitter: Andy Koenig Opened: 2005-07-03 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [tuple].

View all issues with CD1 status.

Discussion:

Tuple doesn't define swap(). It should.

[ Berlin: Doug to provide wording. ]

[ Batavia: Howard to provide wording. ]

[ Toronto: Howard to provide wording (really this time). ]

[ Bellevue: Alisdair provided wording. ]

Proposed resolution:

Add these signatures to 22.4 [tuple]

template <class... Types>
  void swap(tuple<Types...>& x, tuple<Types...>& y);
template <class... Types>
  void swap(tuple<Types...>&& x, tuple<Types...>& y);
template <class... Types>
  void swap(tuple<Types...>& x, tuple<Types...>&& y); 

Add this signature to 22.4.4 [tuple.tuple]

void swap(tuple&&);

Add the following two sections to the end of the tuple clauses

20.3.1.7 tuple swap [tuple.swap]

void swap(tuple&& rhs); 

Requires: Each type in Types shall be Swappable.

Effects: Calls swap for each element in *this and its corresponding element in rhs.

Throws: Nothing, unless one of the element-wise swap calls throw an exception.

20.3.1.8 tuple specialized algorithms [tuple.special]

template <class... Types>
  void swap(tuple<Types...>& x, tuple<Types...>& y);
template <class... Types>
  void swap(tuple<Types...>&& x, tuple<Types...>& y);
template <class... Types>
  void swap(tuple<Types...>& x, tuple<Types...>&& y); 

Effects: x.swap(y)