Книга: Standard Template Library Programmer
max
Разделы на этой странице:
max
Categories: algorithms, utilities
Component type: function
Prototype
Max is an overloaded name; there are actually two max functions.
template <class T>
const T& max(const T& a, const T& b);
template <class T, class BinaryPredicate>
const T& max(const T& a, const T& b, BinaryPredicate comp);
Description
Max returns the greater of its two arguments; it returns the first argument if neither is greater than the other.
The two versions of max differ in how they define whether one element is less than another. The first version compares objects using operator<, and the second compares objects using the function object comp.
Definition
Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
Requirements on types
For the first version:
• T is a model of LessThan Comparable.
For the second version:
• BinaryPredicate is a model of Binary Predicate.
• T is convertible to BinaryPredicate's first argument type and to its second argument type.
Example
const int x = max(3, 9);
assert(x == 9);
See also
min, min_element, max_element, LessThan Comparable
- Пример № 7 Maxwell House
- Глава 9 Подключаемся к 3G, 4G, WI-MaX
- Методы Min, Max
- Несколько слов по поводу WiMax
- Беспроводные сети: Wi-Fi, WiMAX, GPRS, 3G
- 3G с половиной: WiMAX
- Свойства MinimizeBox и MaximizeBox
- Minimum and maximum
- max_element
- Полевой эксперимент в гипермаркете MAXI ICA
- Параметр сокета TCP_MAXSEG
- 5.4. Восстановление данных с поврежденных носителей с помощью программы Max Data Recovery