1379. pair copy-assignment not consistent for references

Section: 23.4.2 [pairs.pair] Status: Resolved Submitter: INCITS Opened: 2010-08-25 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [pairs.pair].

View all issues with Resolved status.

Discussion:

Addresses US-95

Copy-assignment for pair is defaulted and does not work for pairs with reference members. This is inconsistent with conversion-assignment, which deliberately succeeds even if one or both elements are reference types, just as for tuple. The copy-assignment operator should be consistent with the conversion-assignment operator and with tuple's assignment operators.

[ 2010-10-24 Daniel adds: ]

Accepting n3140 would provide a superior resolution, because pair does not depend on the semantic requirements of CopyAssignable.

[ 2010-11 Batavia ]

Resolved by adopting n3140.

Proposed resolution:

Add to pair synopsis:

pair& operator=(const pair& p);

Add before paragraph 9:

pair& operator=(const pair& p);

Requires: T1 and T2 shall satisfy the requirements of CopyAssignable.

Effects: Assigns p.first to first and p.second to second. Returns: *this.