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
minmax
overloads with aninitializer_list
ispair<const T&, const T&>
, which is inconsistent with the decision for the othermin/max
overloads which take ainitializer_list
as argument and return aT
, not aconst T&
. Doing otherwise forminmax
would easily lead to unexpected life-time problems by usingminmax
instead ofmin
andmax
separately.
[ 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_list
form ofminmax
anymore, 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:T
isLessThanComparable
andCopyConstructible
.-21- Returns:
pair<
whereconstT&,constT&>(x, y)x
is the smallest value andy
the 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: typeT
isLessThanComparable
andCopyConstructible
.-25- Returns:
pair<
whereconstT&,constT&>(x, y)x
is the smallest value andy
largest value in theinitializer_list
.