Maybe this question is a little bit theoretic, but I wonder what are the the design incentives behind defining std::minmax
like this
template <class T>
pair<T,T> minmax (initializer_list<T> il);
Which means ,IMO, the passed object, li
will be copied and each of its members must also be copy-constructible.
While, std::min_element
(or for this matter std::max_element
) is more "efficient" in the sense only the container iterators are being passed (no need to actually copy the entire container)
template <class ForwardIterator>
ForwardIterator min_element (ForwardIterator first, ForwardIterator last);
EDIT - based on Joachim Pileborg comment, initializer_list<T>
objects are not being copied, so I'm pinpointing my question - why std::minmax
is constrained to such objects and not to arbitrary containers (which have "non-const" nature, so to speak)