Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 313
towi Avatar asked May 29 '11 12:05

towi


1 Answers

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

like image 188
Howard Hinnant Avatar answered Oct 04 '22 16:10

Howard Hinnant