Search code examples
c++c++11variadic-templatesinitializer-liststl-algorithm

min and max Variadic Template variant in C++11?


Am I right in reading the standard that from min and max (and minmax for that matter) there are new initializer_list variants, but no Variadic Template variants?

Thus, this is ok:

int a = min( { 1,2,a,b,5 } );

but this is not:

int b = min( 1,2,a,b,5 ); // err!

I guess, many people would expect that Variadic Templates could have easily implemented this, therefore they might be disappointed.

I'd say that using V.T. for min and max would be overkill

  • variadic templates are capable of handling multiple types
  • initializer lists check that all types are the same by design

therefore I.L. are much better suited for the task.

Is my interpretation correct?


Solution

  • Your interpretation is correct. N2772 contains more in-depth rationale.