This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD Editorial status.
minmax with initializer_list should return
pair of T, not pair of const T&Section: 26.8.9 [alg.min.max] Status: NAD Editorial Submitter: Daniel Krügler Opened: 2008-10-04 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [alg.min.max].
View all other issues in [alg.min.max].
View all issues with NAD Editorial status.
Discussion:
It seems that the proposed changes for N2772 were not clear enough in this point:
26.8.9 [alg.min.max], before p.23 + p.24 + before p. 27 + p. 28 say that the return type of the
minmaxoverloads with aninitializer_listispair<const T&, const T&>, which is inconsistent with the decision for the othermin/maxoverloads which take ainitializer_listas argument and return aT, not aconst T&. Doing otherwise forminmaxwould easily lead to unexpected life-time problems by usingminmaxinstead ofminandmaxseparately.
[ Batavia (2009-05): ]
We agree with the proposed resolution. Move to Tentatively Ready.
[ 2009-07 Frankfurt ]
Moved from Tentatively Ready to Open only because the wording needs to be tweaked for concepts removal.
[ 2009-08-18 Daniel adds: ]
Recommend NAD since the proposed changes have already been performed as part of editorial work of N2914.
[ 2009-10 Santa Cruz: ]
Can't find
initializer_listform ofminmaxanymore, only variadic version. Seems like we had an editing clash with concepts. Leave Open, at least until editorial issues resolved. Bring this to Editor's attention.
[ 2010 Pittsburgh: Pete to reapply N2772. ]
Rationale:
Solved by reapplying N2772.
Proposed resolution:
In 26 [algorithms]/2, header <algorithm> synopsis change as indicated:
template<classLessThanComparable T> requires CopyConstructible<T> pair<constT&,constT&> minmax(initializer_list<T> t); template<class T,classStrictWeakOrder<auto, T> Compare> requires CopyConstructible<T> pair<constT&,constT&> minmax(initializer_list<T> t, Compare comp);
In 26.8.9 [alg.min.max] change as indicated (Begin: Just before p.20):
template<classLessThanComparable T> requires CopyConstructible<T> pair<constT&,constT&> minmax(initializer_list<T> t);
-20- Requires:TisLessThanComparableandCopyConstructible.-21- Returns:
pair<whereconstT&,constT&>(x, y)xis the smallest value andythe largest value in theinitializer_list.[..]
template<class T,classStrictWeakOrder<auto, T> Compare> requires CopyConstructible<T> pair<constT&,constT&> minmax(initializer_list<T> t, Compare comp);
-24- Requires: typeTisLessThanComparableandCopyConstructible.-25- Returns:
pair<whereconstT&,constT&>(x, y)xis the smallest value andylargest value in theinitializer_list.