A.2.9. Minimum and Maximum Values

These algorithms use either the < operator for the element type or the given comparison operation. The algorithms in the first group operate on values rather than sequences. The algorithms in the second set take a sequence that is denoted by input iterators.

min(val1, val2)min(val1, val2, comp)min(init_list)min(init_list, comp)

max(val1, val2)max(val1, val2, comp)max(init_list)max(init_list, comp)

Returns the minimum/maximum of val1 and val2 or the minimum/maximum value in the initializer_list. The arguments must have exactly the same type as each other. Arguments and the return type are both references to const, meaning that objects are not copied.

minmax(val1, val2)minmax(val1, val2, comp)minmax(init_list) ...

Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.