This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TC1 status.
Section: 22.3 [pairs] Status: TC1 Submitter: Andrew Koenig Opened: 1999-08-03 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [pairs].
View all issues with TC1 status.
Discussion:
The claim has surfaced in Usenet that expressions such as
make_pair("abc", 3)
are illegal, notwithstanding their use in examples, because template instantiation tries to bind the first template
parameter to const char (&)[4]
, which type is uncopyable.
I doubt anyone intended that behavior...
Proposed resolution:
In 22.2 [utility], paragraph 1 change the following declaration of make_pair():
template <class T1, class T2> pair<T1,T2> make_pair(const T1&, const T2&);
to:
template <class T1, class T2> pair<T1,T2> make_pair(T1, T2);
In 22.3 [pairs] paragraph 7 and the line before, change:
template <class T1, class T2> pair<T1, T2> make_pair(const T1& x, const T2& y);
to:
template <class T1, class T2> pair<T1, T2> make_pair(T1 x, T2 y);
and add the following footnote to the effects clause:
According to 12.8 [class.copy], an implementation is permitted to not perform a copy of an argument, thus avoiding unnecessary copies.
Rationale:
Two potential fixes were suggested by Matt Austern and Dietmar Kühl, respectively, 1) overloading with array arguments, and 2) use of a reference_traits class with a specialization for arrays. Andy Koenig suggested changing to pass by value. In discussion, it appeared that this was a much smaller change to the standard that the other two suggestions, and any efficiency concerns were more than offset by the advantages of the solution. Two implementors reported that the proposed resolution passed their test suites.