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

883. swap circular definition

Section: 24 [containers] Status: C++11 Submitter: Alisdair Meredith Opened: 2008-09-10 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [containers].

View all other issues in [containers].

View all issues with C++11 status.

Discussion:

Note in particular that Table 90 "Container Requirements" gives semantics of a.swap(b) as swap(a,b), yet for all containers we define swap(a,b) to call a.swap(b) - a circular definition.

[ San Francisco: ]

Robert to propose a resolution along the lines of "Postcondition: "a = b, b = a" This will be a little tricky for the hash containers, since they don't have operator==.

[ Post Summit Anthony Williams provided proposed wording. ]

[ 2009-07 Frankfurt ]

Moved to Ready with minor edits (which have been made).

Proposed resolution:

In table 80 in section 24.2.2.1 [container.requirements.general], replace the postcondition of a.swap(b) with the following:

Table 80 -- Container requirements
Expression Return type Operational semantics Assertion/note pre-/post-conidtion Complexity
... ... ... ... ...
a.swap(b); void   swap(a,b) Exchange the contents of a and b. (Note A)

Remove the reference to swap from the paragraph following the table.

Notes: the algorithms swap(), equal() and lexicographical_compare() are defined in Clause 25. ...