Книга: Standard Template Library Programmer
min
Разделы на этой странице:
min
Categories: algorithms, utilities
Component type: function
Prototype
Min is an overloaded name; there are actually two min functions.
template <class T>
const T& min(const T& a, const T& b);
template <class T, class BinaryPredicate>
const T& min(const T& a, const T& b, BinaryPredicate comp);
Description
Min returns the lesser of its two arguments; it returns the first argument if neither is less than the other.
The two versions of min 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 = min(3, 9);
assert(x == 3);
See also
max, min_element, max_element, LessThan Comparable
- 9. TERMINATION
- Абстрактный базовый класс FileSystemInfo
- PART V Programming Linux
- CHAPTER 18 Administering Database Services
- Streaming Audio
- Linux Gaming
- Granting System Administrator Privileges to Regular Users
- Controlling Services at Boot with Administrative Tools
- Using Commands for Server Administration
- Administration
- Programming in C
- Using the C Programming Project Management Tools Provided with Fedora Linux