Title
std::pair missing template assignment
Status
resolved
Section
[pairs]
Submitter
Martin Sebor

Created on 2001-12-02.00:00:00 last changed 170 months ago

Messages

Date: 2010-11-19.19:04:45

[ Pre Bellevue: It was recognized that this was taken care of by N1856, and thus moved from NAD Future to NAD EditorialResolved. ]

Date: 2010-10-21.18:28:33

[ Curaçao: There is no indication this is was anything other than a design decision, and thus NAD.  May be appropriate for a future standard. ]

Date: 2010-10-21.18:28:33

Proposed resolution:

Add the following declaration to the definition of std::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 the end 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

Date: 2001-12-02.00:00:00

The class template std::pair defines a template ctor (20.2.2, p4) but no template assignment operator. This may lead to inefficient code since assigning an object of pair<C, D> to pair<A, B> where the types C and D are distinct from but convertible to A and B, respectively, results in a call to the template copy ctor to construct an unnamed temporary of type pair<A, B> followed by an ordinary (perhaps implicitly defined) assignment operator, instead of just a straight assignment.

History
Date User Action Args
2010-11-19 19:04:45adminsetstatus: nad editorial -> resolved
2010-10-21 18:28:33adminsetmessages: + msg2328
2010-10-21 18:28:33adminsetmessages: + msg2327
2010-10-21 18:28:33adminsetmessages: + msg2326
2001-12-02 00:00:00admincreate