sort
Sorts the elements in the range [first,last) in non-descending order. The order of equal elements is not guaranteed to be …
Canonical referenceSection hub
This hub groups algorithms by task first, then points back to the canonical reference page. Ranges forms and execution-policy overloads stay attached to the same conceptual item.
Start here for the small set of algorithms that anchor most day-to-day work: ordering, searching, transformation, partitioning, and numeric accumulation.
Sorts the elements in the range [first,last) in non-descending order. The order of equal elements is not guaranteed to be …
Canonical referenceSorts the elements in the range [first,last) in non-descending order. The order of equivalent elements is guaranteed to be …
Canonical referenceReturns an iterator to the first element in the range [first,last) that satisfies specific criteria (or last if there is no such …
Canonical referenceSearches for the first element in the partitioned range [first,last) which is not ordered before value. # Declarations …
Canonical referencestd::transform applies the given function to the elements of the given input range(s), and stores the result in an output range …
Canonical referenceCopies the elements in the range, defined by [first,last), to another range beginning at d_first (copy destination range). # …
Canonical referenceRemoves all elements satisfying specific criteria from the range [first,last) and returns a past-the-end iterator for the new end …
Canonical referenceReorders the elements in the range [first,last) in such a way that all elements for which the predicate p returns true precede …
Canonical referenceMerges two sorted ranges [first1,last1) and [first2,last2) into one sorted range beginning at d_first. # Declarations template< …
Canonical referenceComputes the sum of the given value init and the elements in the range [first,last). # Declarations template< class InputIt, …
Canonical referenceEach panel groups one algorithm family and keeps the rows compact enough to scan like an index rather than a card wall.
Searches the range [first,last) for two consecutive equal elements. # Declarations template< class …
Checks if unary predicate p returns false for at least one element in the range [first,last). # Declarations …
Checks if unary predicate p returns false for at least one element in the range [first,last). # Declarations …
Checks if an element equivalent to value appears within the partitioned range [first,last). # Declarations …
Returns the number of elements in the range [first,last) satisfying specific criteria. # Declarations …
Returns the number of elements in the range [first,last) satisfying specific criteria. # Declarations …
Returns a range containing all elements equivalent to value in the partitioned range [first,last). # …
Returns an iterator to the first element in the range [first,last) that satisfies specific criteria (or last …
Searches for the last occurrence of the sequence [s_first,s_last) in the range [first,last). # Declarations …
Searches the range [first,last) for any of the elements in the range [s_first,s_last). # Declarations …
Returns an iterator to the first element in the range [first,last) that satisfies specific criteria (or last …
Returns an iterator to the first element in the range [first,last) that satisfies specific criteria (or last …
Searches for the first element in the partitioned range [first,last) which is not ordered before value. # …
Checks if unary predicate p returns false for at least one element in the range [first,last). # Declarations …
Search-based algorithm that checks whether or not a given range contains a value with iterator-sentinel …
Search-based algorithm that checks whether or not a given range contains a value with iterator-sentinel …
Checks whether the second range matches the suffix of the first range. # Declarations Call signature …
Returns the last element in the range [first,last) that satisfies specific criteria: # Declarations Call …
Returns the last element in the range [first,last) that satisfies specific criteria: # Declarations Call …
Returns the last element in the range [first,last) that satisfies specific criteria: # Declarations Call …
Checks whether the second range matches the prefix of the first range. # Declarations Call signature …
1-4) Searches for the first occurrence of the sequence of elements [s_first,s_last) in the range [first,last). …
Searches the range [first,last) for the first sequence of count identical elements, each equal to the given …
Searches for the first element in the partitioned range [first,last) which is ordered after value. # …
Checks whether [first,last) is partitioned by the predicate p: all elements satisfy p appear before all …
Reorders the elements in the range [first,last) in such a way that all elements for which the predicate p …
Copies the elements from the range [first,last) to two different ranges depending on the value returned by …
Examines the partitioned range [first,last) and locates the end of the first partition, that is, the first …
Reorders the elements in the range [first,last) in such a way that all elements for which the predicate p …
Returns true if the sorted range [first2,last2) is a subsequence of the sorted range [first1,last1) (a …
Merges two consecutive sorted ranges [first,middle) and [middle,last) into one sorted range [first,last). # …
Merges two sorted ranges [first1,last1) and [first2,last2) into one sorted range beginning at d_first. # …
Copies the elements from the sorted range [first1,last1) which are not found in the sorted range …
Constructs a sorted range beginning at d_first consisting of elements that are found in both sorted ranges …
Computes symmetric difference of two sorted ranges: the elements that are found in either of the ranges, but …
Constructs a sorted union beginning at d_first consisting of the set of elements present in one or both sorted …
Computes the sum of the given value init and the elements in the range [first,last). # Declarations …
Let T be the value type of decltype(first). # Declarations template< class InputIt, class OutputIt > …
Equivalent to exclusive_scan(first, last, d_first, init, std::plus<>(). # Declarations template< …
Equivalent to inclusive_scan(first, last, d_first, std::plus<>(). # Declarations template< class …
Computes inner product (i.e. sum of products) or performs ordered map/reduce operation on the range …
Fills the range [first,last) with sequentially increasing values, starting with value and repetitively …
If [first,last) is empty, does nothing. # Declarations template< class InputIt, class OutputIt > …
Left-folds the elements of given range, that is, returns the result of evaluation of the chain …
Left-folds the elements of given range, that is, returns the result of evaluation of the chain …
Left-folds the elements of given range, that is, returns the result of evaluation of the chain …
Left-folds the elements of given range, that is, returns the result of evaluation of the chain …
Right-folds the elements of given range, that is, returns the result of evaluation of the chain …
Right-folds the elements of given range, that is, returns the result of evaluation of the chain …
Equivalent to reduce(first, last, typename std::iterator_traits::value_type{}). # Declarations template< …
Computes the exclusive prefix sum using op. # Declarations template< class InputIt, class OutputIt, class …
Computes the inclusive prefix sum using op. # Declarations template< class InputIt, class OutputIt, class …
Equivalent to transform_reduce(first1, last1, first2, init,std::plus<>(), std::multiplies<>()), …
Checks whether [first1,last1) is a permutation of a range starting from first2: # Declarations template< …
Permutes the range [first,last) into the next permutation. Returns true if such a “next permutation” exists; …
Transforms the range [first,last) into the previous permutation. Returns true if such permutation exists, …
Reorders the elements in the given range [first,last) such that each possible permutation of those elements …
Selects n elements from the sequence [first,last) (without replacement) such that each possible sample has …
Reorders the elements in the given range [first,last) such that each possible permutation of those elements …
Checks if the elements in range [first,last) are sorted in non-descending order. # Declarations template< …
Examines the range [first,last) and finds the largest range beginning at first in which the elements are …
nth_element rearranges elements in [first,last) such that after the rearrangement: # Declarations template< …
Rearranges elements such that the range [first,middle) contains the sorted middle − first smallest elements in …
Sorts some of the elements in the range [first,last) in ascending order, storing the result in the range …
Sorts the elements in the range [first,last) in non-descending order. The order of equal elements is not …
Sorts the elements in the range [first,last) in non-descending order. The order of equivalent elements is …
Copies the elements in the range, defined by [first,last), to another range beginning at d_first (copy …
Copies the elements from the range [first,last) to another range ending at d_last. The elements are copied in …
Copies the elements in the range, defined by [first,last), to another range beginning at d_first (copy …
Copies exactly count values from the range beginning at first to the range beginning at result. Formally, for …
Assigns the given value to all elements in the range [first,last). # Declarations template< class …
Assigns the given value to the first count elements in the range beginning at first if count > 0. Does …
Applies the given function object f to the result of dereferencing every iterator in the range [first,last). …
Applies the given function object f to the result of dereferencing every iterator in the range [first,first + …
Assigns each element in range [first,last) a value generated by the given function object g. # Declarations …
Assigns values, generated by given function object g, to the first count elements in the range beginning at …
Swaps the values of the elements the given iterators are pointing to. # Declarations template< class …
Moves the elements in the range [first,last), to another range beginning at d_first, starting from first and …
Moves the elements from the range [first,last), to another range ending at d_last. The elements are moved in …
Attempts to generate random numbers with the generate_random member function of the random number generator or …
Removes all elements satisfying specific criteria from the range [first,last) and returns a past-the-end …
Copies elements from the range [first,last), to another range beginning at d_first, omitting the elements …
Copies elements from the range [first,last), to another range beginning at d_first, omitting the elements …
Removes all elements satisfying specific criteria from the range [first,last) and returns a past-the-end …
Replaces all elements in the range [first,last) with new_value if they satisfy specific criteria. # …
Copies the elements from the range [first,last) to another range beginning at d_first, while replacing all …
Copies the elements from the range [first,last) to another range beginning at d_first, while replacing all …
Replaces all elements in the range [first,last) with new_value if they satisfy specific criteria. # …
Reverses the order of the elements in the range [first,last). # Declarations template< class BidirIt > …
Given (\scriptsize N)N as std::distance(first, last). Copies the elements from the range [first,last) (source …
Performs a left rotation on a range of elements. # Declarations template< class ForwardIt > ForwardIt …
Copies the elements from the range [first,last), to another range beginning at d_first in such a way, that …
Shifts the elements in the range [first,last) by n positions. # Declarations template< class ForwardIt > …
Shifts the elements in the range [first,last) by n positions. # Declarations template< class ForwardIt > …
Exchanges the given values. # Declarations template< class T > void swap( T& a, T& b ); …
Exchanges elements between range [first1,last1) and another range of std::distance(first1, last1) elements …
std::transform applies the given function to the elements of the given input range(s), and stores the result …
Removes all except the first element from every consecutive group of equivalent elements from the range …
Copies the elements from the range [first,last), to another range beginning at d_first in such a way that …
If the value of v is within [lo,hi], returns v; otherwise returns the nearest boundary. # Declarations …
Checks whether [first1,last1) and a range starting from first2 are equal: # Declarations template< class …
Checks if the first range [first1,last1) is lexicographically less than the second range [first2,last2). # …
Lexicographically compares two ranges [first1,last1) and [first2,last2) using three-way comparison and …
Returns the greater of the given values. # Declarations template< class T > const T& max( const …
Finds the greatest element in the range [first,last). # Declarations template< class ForwardIt > …
Returns the smaller of the given values. # Declarations template< class T > const T& min( const …
Finds the smallest element in the range [first,last). # Declarations template< class ForwardIt > …
Returns the lowest and the greatest of the given values. # Declarations template< class T > …
Finds the smallest and greatest element in the range [first,last). # Declarations template< class ForwardIt …
Returns a pair of iterators to the first mismatching of elements from [first1,last1) and a range starting from …
Checks whether [first,last) is a heap. # Declarations template< class RandomIt > bool is_heap( RandomIt …
Examines the range [first,last) and finds the largest range beginning at first which is a heap. # Declarations …
Constructs a heap in the range [first,last). # Declarations template< class RandomIt > void make_heap( …
Swaps the value in the position first and the value in the position last - 1 and makes the subrange …
Inserts the element at the position last - 1 into the heap [first,last - 1). The heap after the insertion will …
Converts the heap [first,last) into a sorted range. The heap property is no longer maintained. # Declarations …
Finds an element equal to element pointed to by key in an array pointed to by ptr. The array contains count …
Sorts the given array pointed to by ptr in ascending order. The array contains count elements of size bytes. …