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.

### 915. `minmax` with `initializer_list` should return `pair` of `T`, not `pair` of `const T&`

Section: 25.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 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:

> 25.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 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.

[ 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 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.

[ 2010 Pittsburgh: Pete to reapply N2772. ]

Rationale:

Solved by reapplying N2772.

Proposed resolution:

1. In 25 [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 25.8.9 [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`.