This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofResolved status.
std::pair missing template assignmentSection: 22.3[pairs]Status:ResolvedSubmitter: Martin SeborOpened: 2001-12-02Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [pairs].
View all issues withResolved status.
Discussion:
The class templatestd::pair defines a template ctor (20.2.2, p4) butno template assignment operator. This may lead to inefficient code sinceassigning an object ofpair<C, D> topair<A, B>where the typesC andD are distinct from but convertible toA andB, respectively, results in a call to the template copyctor to construct an unnamed temporary of typepair<A, B>followed by an ordinary (perhaps implicitly defined) assignment operator,instead of just a straight assignment.
Proposed resolution:
Add the following declaration to the definition ofstd::pair:
template<class U, class V> pair& operator=(const pair<U, V> &p);
And also add a paragraph describing the effects of the function template to theend of 20.2.2:
template<class U, class V> pair& operator=(const pair<U, V> &p);
Effects:first = p.first;second = p.second;Returns:*this
[Curaçao: There is no indication this is was anything other thana design decision, and thus NAD. May be appropriate for a futurestandard.]
[Pre Bellevue: It was recognized that this was taken care of byN1856,and thus moved from NAD Future toNAD EditorialResolved.]