We can use std::min
in below way:
// 1.
int a = 1, b = 2;
std::min(a, b);
// 2.
std::min({1,2,3,4});
But why can't use a std::vector
or std::list
, Because the param in the template is initializer_list
.
template <class T, class Compare>
pair<T,T> minmax (initializer_list<T> il, Compare comp);
What is the reason for this design?