std::max_element — iterator to the largest element
std::max_element searches a range and returns an iterator to its first largest element. An empty range yields last; an optional comparator determines the ordering.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
std::max_element searches a range and returns an iterator to its first largest element. An empty range yields last; an optional comparator determines the ordering.
std::memcpy from <cstring> copies a specified number of bytes between non-overlapping memory regions. It does not check bounds and is not a replacement for copying resource-owning objects.
std::memory_order from <atomic> specifies ordering and synchronization for atomic operations. It distinguishes atomicity alone from safely publishing data between threads; incorrectly weakening an order can introduce a data race.
std::merge from <algorithm> copies two sorted ranges into a separate output range. It preserves duplicates and stability, and returns an iterator one past the last element written.
std::min from <algorithm> selects the smaller of two arguments or the minimum of a nonempty list. The two-argument overload returns a reference, while the list overload returns a copy; an optional comparator defines the ordering.
std::min_element from <algorithm> returns an iterator to the first smallest element in a range. It does not sort the data. For an empty range it returns last, so check the iterator before reading the result.
std::minmax from <algorithm> finds the minimum and maximum together. The two-argument overload returns a pair of references, whereas the initializer-list overload returns a pair of copied values.
std::minmax_element finds a range's minimum and maximum and returns a pair of iterators. Ties select the first minimum and last maximum; an empty range requires checking the result before dereferencing.
std::move from <utility> exposes an object as an xvalue, enabling selection of a move operation. The call itself neither transfers resources nor empties the object; the actual effect depends on the operation that consumes its result.
std::move_backward assigns range elements from last to first while preserving their order in the destination. It supports safely shifting an overlapping range to the right.
C++23 std::move_only_function stores a callable with a specified signature, including a lambda owning an exclusive resource. The wrapper can be moved but not copied. It must contain a target before it is called.
std::multimap from <map> stores key–value pairs in key order and allows multiple elements with equivalent keys. equal_range retrieves the entire matching group, while erase(key) removes every element in that group.
std::multiset from <set> stores keys in comparator-defined order and permits equivalent keys. Learn how lookup and counting work, and distinguish removing one element from removing every equivalent element.
std::mutex from <mutex> allows only one thread at a time to own its lock. It protects shared data when all conflicting accesses follow the same locking protocol. std::lock_guard manages lock release within a scope.
std::nano is a type alias from <ratio> representing the exact factor 1/1,000,000,000. It exposes the numerator num and denominator den as compile-time constants; it is neither a floating-point number nor a unit of time.
std::next from <iterator> returns a copy of an iterator advanced by n positions, defaulting to one. It also supports iterators without operator +. It does not check range boundaries; a negative offset requires a bidirectional iterator.
std::next_permutation rearranges a range into its next lexicographical permutation. It returns true when a successor exists; after the final permutation, it restores the first arrangement and returns false.
std::none_of from <algorithm> checks whether no element in a range satisfies a predicate. It returns bool: true means there are no matches, while false means at least one match exists. An empty range produces true.
std::noop_coroutine() returns a non-null handle to a special coroutine whose resumption and destruction have no observable effects. It is not an empty handle.
std::nth_element places an element at the position it would occupy after a full sort without sorting the entire range. It is useful for finding a median or the kth smallest element.
std::numeric_limits<T> from <limits> exposes the limits and representation properties of T. Learn how min() differs from lowest(), what digits measures, and how to check IEC 559 conformance without assuming a particular type size.
std::ofstream from <fstream> writes data to a file through a stream interface. Learn about default content replacement, appending, and checking errors when opening, writing, and closing a file.
std::optional<T> represents either an object of type T or no value. It separates a missing result from valid values such as 0. Check that a value is present before using the * and -> operators.
std::basic_ostream is an output-stream template, and std::ostream is its alias for char. They support formatting values with operator<< and writing characters to an associated stream buffer.