Title
minmax with initializer_list should return pair of T, not pair of const T&
Status
nad editorial
Section
[alg.min.max]
Submitter
Daniel Krügler

Created on 2008-10-04.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

  1. In [algorithms]/2, header <algorithm> synopsis change as indicated:

    template<classLessThanComparable T>
    requires CopyConstructible<T>
    pair<const T&, const T&>
    minmax(initializer_list<T> t);
    
    template<class T, classStrictWeakOrder<auto, T> Compare>
    requires CopyConstructible<T>
    pair<const T&, const T&>
    minmax(initializer_list<T> t, Compare comp);
    
  2. In [alg.min.max] change as indicated (Begin: Just before p.20):

    template<classLessThanComparable T>
      requires CopyConstructible<T>
      pair<const T&, const T&>
      minmax(initializer_list<T> t);
    

    -20- Requires: T is LessThanComparable and CopyConstructible.

    -21- Returns: pair<const T&, const T&>(x, y) where x is the smallest value and y the largest value in the initializer_list.

    [..]

    template<class T, classStrictWeakOrder<auto, T> Compare>
      requires CopyConstructible<T>
      pair<const T&, const T&>
      minmax(initializer_list<T> t, Compare comp);
    

    -24- Requires: type T is LessThanComparable and CopyConstructible.

    -25- Returns: pair<const T&, const T&>(x, y) where x is the smallest value and y largest value in the initializer_list.

Date: 2011-03-05.21:44:45

Rationale:

Solved by reapplying N2772.

Date: 2010-10-21.18:28:33

[ 2010 Pittsburgh: Pete to reapply N2772. ]

Date: 2010-10-21.18:28:33

[ 2009-10 Santa Cruz: ]

Can't find initializer_list form of minmax 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.

Date: 2009-08-18.00:00:00

[ 2009-08-18 Daniel adds: ]

Recommend NAD since the proposed changes have already been performed as part of editorial work of N2914.

Date: 2010-10-21.18:28:33

[ 2009-07 Frankfurt ]

Moved from Tentatively Ready to Open only because the wording needs to be tweaked for concepts removal.

Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to Tentatively Ready.

Date: 2008-10-04.00:00:00

It seems that the proposed changes for N2772 were not clear enough in this point:

[alg.min.max], before p.23 + p.24 + before p. 27 + p. 28 say that the return type of the minmax overloads with an initializer_list is pair<const T&, const T&>, which is inconsistent with the decision for the other min/max overloads which take a initializer_list as argument and return a T, not a const T&. Doing otherwise for minmax would easily lead to unexpected life-time problems by using minmax instead of min and max separately.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg4346
2010-10-21 18:28:33adminsetmessages: + msg4345
2010-10-21 18:28:33adminsetmessages: + msg4344
2010-10-21 18:28:33adminsetmessages: + msg4343
2010-10-21 18:28:33adminsetmessages: + msg4342
2010-10-21 18:28:33adminsetmessages: + msg4341
2010-10-21 18:28:33adminsetmessages: + msg4340
2008-10-04 00:00:00admincreate