tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches

Algorithms that operate on ranges. More...

Classes

struct  in_fun_result< I, F >
 

Functions

template<typename InputIt , typename OutputIt >
constexpr auto copy (InputIt first, InputIt last, OutputIt destination) -> OutputIt
 Copies the elements in the range, defined by [first, last), to another range beginning at destination.
 
template<typename BidirIt1 , typename BidirIt2 >
constexpr auto copy_backward (BidirIt1 first, BidirIt1 last, BidirIt2 dLast) -> BidirIt2
 Copies the elements from the range, defined by [first, last), to another range ending at dLast. The elements are copied in reverse order (the last element is copied first), but their relative order is preserved.
 
template<typename InIt , typename OutIt , typename Pred >
constexpr auto copy_if (InIt first, InIt last, OutIt dFirst, Pred pred) -> OutIt
 Copies the elements in the range, defined by [first, last), to another range beginning at destination.
 
template<typename InputIt , typename Size , typename OutputIt >
constexpr auto copy_n (InputIt first, Size count, OutputIt result) -> OutputIt
 Copies exactly count values from the range beginning at first to the range beginning at result. Formally, for each integer 0 <= i < count, performs *(result + i) = *(first + i). Overlap of ranges is formally permitted, but leads to unpredictable ordering of the results.
 
template<typename InputIt , typename T >
constexpr auto count (InputIt first, InputIt last, T const &value) -> typename iterator_traits< InputIt >::difference_type
 Returns the number of elements in the range [first, last) satisfying specific criteria. Counts the elements that are equal to value.
 
template<typename InputIt , typename Predicate >
constexpr auto count_if (InputIt first, InputIt last, Predicate p) -> typename iterator_traits< InputIt >::difference_type
 Returns the number of elements in the range [first, last) satisfying specific criteria. Counts elements for which predicate p returns true.
 
template<typename InputIt1 , typename InputIt2 >
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2) -> bool
 
template<typename InputIt1 , typename InputIt2 >
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename Predicate >
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Predicate p) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename Predicate >
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, Predicate p) -> bool
 Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1)), and false otherwise.
 
template<typename ForwardIt , typename T >
constexpr auto equal_range (ForwardIt first, ForwardIt last, T const &value) -> pair< ForwardIt, ForwardIt >
 
template<typename ForwardIt , typename T , typename Compare >
constexpr auto equal_range (ForwardIt first, ForwardIt last, T const &value, Compare comp) -> pair< ForwardIt, ForwardIt >
 Returns a range containing all elements equivalent to value in the range [first, last).
 
template<typename RandomIt >
constexpr auto exchange_sort (RandomIt first, RandomIt last) -> void
 Sorts the elements in the range [first, last) in non-descending order.
 
template<typename RandomIt , typename Compare >
constexpr auto exchange_sort (RandomIt first, RandomIt last, Compare comp) -> void
 Sorts the elements in the range [first, last) in non-descending order.
 
template<typename ForwardIt , typename T >
constexpr auto fill (ForwardIt first, ForwardIt last, T const &value) -> void
 Assigns the given value to the elements in the range [first, last).
 
template<typename OutputIt , typename Size , typename T >
constexpr auto fill_n (OutputIt first, Size count, T const &value) -> OutputIt
 Assigns the given value to the first count elements in the range beginning at first if count > 0. Does nothing otherwise.
 
template<typename InputIt , typename T >
constexpr auto find (InputIt first, InputIt last, T const &value) noexcept -> InputIt
 Searches for an element equal to value.
 
template<typename ForwardIt1 , typename ForwardIt2 >
constexpr auto find_end (ForwardIt1 first, ForwardIt1 last, ForwardIt2 sFirst, ForwardIt2 sLast) -> ForwardIt1
 
template<typename ForwardIt1 , typename ForwardIt2 , typename Predicate >
constexpr auto find_end (ForwardIt1 first, ForwardIt1 last, ForwardIt2 sFirst, ForwardIt2 sLast, Predicate p) -> ForwardIt1
 Searches for the last occurrence of the sequence [sFirst, sLast) in the range [first, last). Elements are compared using the given binary predicate p.
 
template<typename InputIt , typename ForwardIt >
constexpr auto find_first_of (InputIt first, InputIt last, ForwardIt sFirst, ForwardIt sLast) -> InputIt
 Searches the range [first, last) for any of the elements in the range [sFirst, sLast).
 
template<typename InputIt , typename ForwardIt , typename Predicate >
constexpr auto find_first_of (InputIt first, InputIt last, ForwardIt sFirst, ForwardIt sLast, Predicate pred) -> InputIt
 Searches the range [first, last) for any of the elements in the range [sFirst, sLast). Elements are compared using the given binary predicate pred.
 
template<typename InputIt , typename Predicate >
constexpr auto find_if (InputIt first, InputIt last, Predicate pred) noexcept -> InputIt
 Searches for an element for which predicate p returns true.
 
template<typename InputIt , typename Predicate >
constexpr auto find_if_not (InputIt first, InputIt last, Predicate pred) noexcept -> InputIt
 Searches for an element for which predicate q returns false.
 
template<typename InputIt , typename UnaryFunc >
constexpr auto for_each (InputIt first, InputIt last, UnaryFunc f) noexcept -> UnaryFunc
 Applies the given function object f to the result of dereferencing every iterator in the range [first, last) in order.
 
template<typename InputIt , typename Size , typename UnaryFunc >
constexpr auto for_each_n (InputIt first, Size n, UnaryFunc f) noexcept -> InputIt
 Applies the given function object f to the result of dereferencing every iterator in the range [first, first + n] in order.
 
template<typename ForwardIt , typename Generator >
constexpr auto generate (ForwardIt first, ForwardIt last, Generator g) -> void
 Assigns each element in range [first, last) a value generated by the given function object g.
 
template<typename OutputIt , typename SizeT , typename Generator >
constexpr auto generate_n (OutputIt first, SizeT count, Generator g) -> OutputIt
 Assigns values, generated by given function object g, to the first count elements in the range beginning at first, if count > 0. Does nothing otherwise.
 
template<typename BidirIt >
constexpr auto gnome_sort (BidirIt first, BidirIt last) -> void
 Sorts the elements in the range [first, last) in non-descending order.
 
template<typename BidirIt , typename Compare >
constexpr auto gnome_sort (BidirIt first, BidirIt last, Compare comp) -> void
 Sorts the elements in the range [first, last) in non-descending order.
 
template<typename InputIt1 , typename InputIt2 >
constexpr auto includes (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename Compare >
constexpr auto includes (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) -> bool
 Returns true if the sorted range [first2, last2) is a subsequence of the sorted range [first1, last1). Both ranges must be sorted.
 
template<typename BidirIt , typename Compare >
constexpr auto inplace_merge (BidirIt begin, BidirIt mid, BidirIt end, Compare comp) -> void
 Merges two consecutive sorted ranges [first, middle) and [middle, last) into one sorted range [first, last).
 
template<typename BidirIt >
constexpr auto inplace_merge (BidirIt first, BidirIt mid, BidirIt last) -> void
 
template<typename RandomIt >
constexpr auto insertion_sort (RandomIt first, RandomIt last) -> void
 
template<typename RandomIt , typename Compare >
constexpr auto insertion_sort (RandomIt first, RandomIt last, Compare comp) -> void
 Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is guaranteed to be preserved.
 
template<typename InputIt , typename Predicate >
constexpr auto is_partitioned (InputIt first, InputIt last, Predicate p) -> bool
 Returns true if all elements in the range [first, last) that satisfy the predicate p appear before all elements that don't. Also returns true if the range is empty.
 
template<typename ForwardIt1 , typename ForwardIt2 >
constexpr auto is_permutation (ForwardIt1 first, ForwardIt1 last, ForwardIt2 first2) -> bool
 Returns true if there exists a permutation of the elements in the range [first1, last1) that makes that range equal to the range [first2, last2), where last2 denotes first2 + (last1 - first1) if it was not given.
 
template<typename ForwardIt1 , typename ForwardIt2 >
constexpr auto is_permutation (ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2) -> bool
 
template<typename ForwardIt >
constexpr auto is_sorted (ForwardIt first, ForwardIt last) -> bool
 Checks if the elements in range [first, last) are sorted in non-descending order.
 
template<typename ForwardIt , typename Compare >
constexpr auto is_sorted (ForwardIt first, ForwardIt last, Compare comp) -> bool
 
template<typename ForwardIt >
constexpr auto is_sorted_until (ForwardIt first, ForwardIt last) -> ForwardIt
 Examines the range [first, last) and finds the largest range beginning at first in which the elements are sorted in non-descending order.
 
template<typename ForwardIt , typename Compare >
constexpr auto is_sorted_until (ForwardIt first, ForwardIt last, Compare comp) -> ForwardIt
 
template<typename ForwardIt1 , typename ForwardIt2 >
constexpr auto iter_swap (ForwardIt1 a, ForwardIt2 b) -> void
 Swaps the values of the elements the given iterators are pointing to.
 
template<typename InputIt1 , typename InputIt2 >
constexpr auto lexicographical_compare (InputIt1 f1, InputIt1 l1, InputIt2 f2, InputIt2 l2) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename Compare >
constexpr auto lexicographical_compare (InputIt1 f1, InputIt1 l1, InputIt2 f2, InputIt2 l2, Compare comp) -> bool
 Checks if the first range [f1, l1) is lexicographically less than the second range [f2, l2).
 
template<typename ForwardIt , typename T >
constexpr auto lower_bound (ForwardIt first, ForwardIt last, T const &value) noexcept -> ForwardIt
 
template<typename ForwardIt , typename T , typename Compare >
constexpr auto lower_bound (ForwardIt first, ForwardIt last, T const &value, Compare comp) noexcept -> ForwardIt
 Returns an iterator pointing to the first element in the range [first, last) that is not less than (i.e. greater or equal to) value, or last if no such element is found.
 
template<typename Type >
constexpr auto max (Type const &a, Type const &b) noexcept -> Type const &
 Returns the greater of a and b.
 
template<typename Type , typename Compare >
constexpr auto max (Type const &a, Type const &b, Compare comp) noexcept -> Type const &
 Returns the greater of a and b, using a compare function.
 
template<typename ForwardIt >
constexpr auto max_element (ForwardIt first, ForwardIt last) noexcept -> ForwardIt
 Finds the greatest element in the range [first, last). Elements are compared using operator<.
 
template<typename ForwardIt , typename Compare >
constexpr auto max_element (ForwardIt first, ForwardIt last, Compare comp) -> ForwardIt
 Finds the greatest element in the range [first, last). Elements are compared using the given binary comparison function comp.
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt >
constexpr auto merge (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination) -> OutputIt
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt , typename Compare >
constexpr auto merge (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination, Compare comp) -> OutputIt
 Merges two sorted ranges [first1, last1) and [first2, last2) into one sorted range beginning at destination.
 
template<typename Type >
constexpr auto min (Type const &a, Type const &b) noexcept -> Type const &
 Returns the smaller of a and b.
 
template<typename Type , typename Compare >
constexpr auto min (Type const &a, Type const &b, Compare comp) noexcept -> Type const &
 Returns the smaller of a and b, using a compare function.
 
template<typename ForwardIt >
constexpr auto min_element (ForwardIt first, ForwardIt last) noexcept -> ForwardIt
 Finds the smallest element in the range [first, last). Elements are compared using operator<.
 
template<typename ForwardIt , typename Compare >
constexpr auto min_element (ForwardIt first, ForwardIt last, Compare comp) -> ForwardIt
 Finds the smallest element in the range [first, last). Elements are compared using the given binary comparison function comp.
 
template<typename T >
constexpr auto minmax (T const &a, T const &b) -> pair< T const &, T const & >
 Returns the lowest and the greatest of the given values.
 
template<typename T , typename Compare >
constexpr auto minmax (T const &a, T const &b, Compare comp) -> pair< T const &, T const & >
 Returns the lowest and the greatest of the given values.
 
template<typename ForwardIt >
constexpr auto minmax_element (ForwardIt first, ForwardIt last) -> pair< ForwardIt, ForwardIt >
 Finds the smallest and greatest element in the range [first, last).
 
template<typename ForwardIt , typename Compare >
constexpr auto minmax_element (ForwardIt first, ForwardIt last, Compare comp) -> pair< ForwardIt, ForwardIt >
 Finds the smallest and greatest element in the range [first, last).
 
template<typename InputIt1 , typename InputIt2 , typename Predicate >
constexpr auto mismatch (InputIt1 first1, InputIt1 last1, InputIt2 first2, Predicate pred) -> pair< InputIt1, InputIt2 >
 Returns the first mismatching pair of elements from two ranges: one defined by [first1, last1) and another defined by [first2,last2). If last2 is not provided (overloads (1-4)), it denotes first2 + (last1 - first1). Elements are compared using the given binary predicate pred.
 
template<typename InputIt , typename OutputIt >
constexpr auto move (InputIt first, InputIt last, OutputIt destination) -> OutputIt
 Moves the elements in the range [first, last), to another range beginning at destination, starting from first and proceeding to last - 1. After this operation the elements in the moved-from range will still contain valid values of the appropriate type, but not necessarily the same values as before the move.
 
template<typename BidirIt1 , typename BidirIt2 >
constexpr auto move_backward (BidirIt1 first, BidirIt1 last, BidirIt2 destination) -> BidirIt2
 Moves the elements from the range [first, last), to another range ending at destination. The elements are moved in reverse order (the last element is moved first), but their relative order is preserved.
 
template<typename InputIt , typename Predicate >
constexpr auto none_of (InputIt first, InputIt last, Predicate p) -> bool
 Checks if unary predicate p returns true for no elements in the range [first, last).
 
template<typename RandomIt , typename Compare >
constexpr auto nth_element (RandomIt first, RandomIt nth, RandomIt last, Compare comp) -> void
 nth_element is a partial sorting algorithm that rearranges elements in [first, last) such that:
 
template<typename RandomIt , typename Compare >
constexpr auto partial_sort (RandomIt first, RandomIt middle, RandomIt last, Compare comp) -> void
 Rearranges elements such that the range [first, middle) contains the sorted middle - first smallest elements in the range [first, last). The order of equal elements is not guaranteed to be preserved. The order of the remaining elements in the range [middle, last) is unspecified.
 
template<typename ForwardIt , typename Predicate >
constexpr auto partition (ForwardIt first, ForwardIt last, Predicate p) -> ForwardIt
 Reorders the elements in the range [first, last) in such a way that all elements for which the predicate p returns true precede the elements for which predicate p returns false. Relative order of the elements is not preserved.
 
template<typename InputIt , typename OutputIt1 , typename OutputIt2 , typename Predicate >
constexpr auto partition_copy (InputIt first, InputIt last, OutputIt1 destinationTrue, OutputIt2 destinationFalse, Predicate p) -> pair< OutputIt1, OutputIt2 >
 Copies the elements from the range [first, last) to two different ranges depending on the value returned by the predicate p. The elements that satisfy the predicate p are copied to the range beginning at destination_true. The rest of the elements are copied to the range beginning at destination_false.
 
template<typename ForwardIt , typename Predicate >
constexpr auto partition_point (ForwardIt first, ForwardIt last, Predicate p) -> ForwardIt
 Examines the partitioned (as if by partition) range [first, last) and locates the end of the first partition, that is, the first element that does not satisfy p or last if all elements satisfy p.
 
template<typename ForwardIt , typename T >
constexpr auto remove (ForwardIt first, ForwardIt last, T const &value) -> ForwardIt
 Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range.
 
template<typename InputIt , typename OutputIt , typename T >
constexpr auto remove_copy (InputIt first, InputIt last, OutputIt destination, T const &value) -> OutputIt
 Copies elements from the range [first, last), to another range beginning at destination, omitting the elements which satisfy specific criteria. Source and destination ranges cannot overlap. Ignores all elements that are equal to value.
 
template<typename InputIt , typename OutputIt , typename Predicate >
constexpr auto remove_copy_if (InputIt first, InputIt last, OutputIt destination, Predicate p) -> OutputIt
 Copies elements from the range [first, last), to another range beginning at destination, omitting the elements which satisfy specific criteria. Source and destination ranges cannot overlap. Ignores all elements for which predicate p returns true.
 
template<typename ForwardIt , typename Predicate >
constexpr auto remove_if (ForwardIt first, ForwardIt last, Predicate pred) -> ForwardIt
 Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range.
 
template<typename ForwardIt , typename T >
constexpr auto replace (ForwardIt first, ForwardIt last, T const &oldValue, T const &newValue) -> void
 Replaces all elements satisfying specific criteria with new_value in the range [first, last). Replaces all elements that are equal to old_value.
 
template<typename ForwardIt , typename Predicate , typename T >
constexpr auto replace_if (ForwardIt first, ForwardIt last, Predicate p, T const &newValue) -> void
 Replaces all elements satisfying specific criteria with new_value in the range [first, last). Replaces all elements for which predicate p returns true.
 
template<typename BidirIt >
constexpr auto reverse (BidirIt first, BidirIt last) -> void
 Reverses the order of the elements in the range [first, last).
 
template<typename BidirIt , typename OutputIt >
constexpr auto reverse_copy (BidirIt first, BidirIt last, OutputIt destination) -> OutputIt
 Copies the elements from the range [first, last) to another range beginning at d_first in such a way that the elements in the new range are in reverse order.
 
template<typename ForwardIt >
constexpr auto rotate (ForwardIt first, ForwardIt nFirst, ForwardIt last) -> ForwardIt
 Performs a left rotation on a range of elements.
 
template<typename ForwardIt , typename OutputIt >
constexpr auto rotate_copy (ForwardIt first, ForwardIt nFirst, ForwardIt last, OutputIt destination) -> OutputIt
 Copies the elements from the range [first, last), to another range beginning at destination in such a way, that the element nFirst becomes the first element of the new range and nFirst - 1 becomes the last element.
 
template<typename ForwardIt >
constexpr auto shift_left (ForwardIt first, ForwardIt const last, typename iterator_traits< ForwardIt >::difference_type n) -> ForwardIt
 Shifts the elements in the range [first, last) by n positions.
 
template<typename BidiIt >
constexpr auto shift_right (BidiIt first, BidiIt last, typename etl::iterator_traits< BidiIt >::difference_type n) -> BidiIt
 Shifts the elements in the range [first, last) by n positions.
 
template<typename BidirIt , typename Predicate >
constexpr auto stable_partition (BidirIt f, BidirIt l, Predicate p) -> BidirIt
 Reorders the elements in the range [first, last) in such a way that all elements for which the predicate p returns true precede the elements for which predicate p returns false. Relative order of the elements is preserved.
 
template<typename ForwardIt1 , typename ForwardIt2 >
constexpr auto swap_ranges (ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2) -> ForwardIt2
 Exchanges elements between range [first1 ,last1) and another range starting at first2.
 
template<typename ForwardIt , typename Predicate >
constexpr auto adjacent_find (ForwardIt first, ForwardIt last, Predicate pred) -> ForwardIt
 Searches the range [first, last) for two consecutive equal elements. Elements are compared using the given binary predicate p.
 
template<typename ForwardIt >
constexpr auto adjacent_find (ForwardIt first, ForwardIt last) -> ForwardIt
 Searches the range [first, last) for two consecutive equal elements. Elements are compared using the given binary predicate p.
 
template<typename InputIt , typename Predicate >
constexpr auto all_of (InputIt first, InputIt last, Predicate p) -> bool
 Checks if unary predicate p returns true for all elements in the range [first, last).
 
template<typename InputIt , typename Predicate >
constexpr auto any_of (InputIt first, InputIt last, Predicate p) -> bool
 Checks if unary predicate p returns true for at least one element in the range [first, last).
 
template<typename ForwardIt , typename T , typename Compare >
constexpr auto binary_search (ForwardIt first, ForwardIt last, T const &value, Compare comp) -> bool
 
template<typename ForwardIt , typename T >
constexpr auto binary_search (ForwardIt first, ForwardIt last, T const &value) -> bool
 
template<typename RandomIt , typename Compare >
constexpr auto bubble_sort (RandomIt first, RandomIt last, Compare comp) -> void
 Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is guaranteed to be preserved.
 
template<typename RandomIt >
constexpr auto bubble_sort (RandomIt first, RandomIt last) -> void
 Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is guaranteed to be preserved.
 
template<typename Type , typename Compare >
constexpr auto clamp (Type const &v, Type const &lo, Type const &hi, Compare comp) -> Type const &
 If v compares less than lo, returns lo; otherwise if hi compares less than v, returns hi; otherwise returns v. Uses operator< to compare the values.
 
template<typename Type >
constexpr auto clamp (Type const &v, Type const &lo, Type const &hi) noexcept -> Type const &
 If v compares less than lo, returns lo; otherwise if hi compares less than v, returns hi; otherwise returns v. Uses operator< to compare the values.
 
template<typename BidirIt , typename Compare >
constexpr auto merge_sort (BidirIt first, BidirIt last, Compare comp) -> void
 Sorts the elements in the range [first, last) in non-descending order.
 
template<typename BidirIt >
constexpr auto merge_sort (BidirIt first, BidirIt last) -> void
 Sorts the elements in the range [first, last) in non-descending order.
 
template<typename FwdIt1 , typename FwdIt2 , typename Predicate >
constexpr auto search (FwdIt1 first, FwdIt1 last, FwdIt2 sFirst, FwdIt2 sLast, Predicate pred) -> FwdIt1
 
template<typename FwdIt1 , typename FwdIt2 >
constexpr auto search (FwdIt1 first, FwdIt1 last, FwdIt2 sFirst, FwdIt2 sLast) -> FwdIt1
 
template<typename FwdIt , typename Searcher >
constexpr auto search (FwdIt first, FwdIt last, Searcher const &searcher) -> FwdIt
 
template<typename ForwardIt , typename Size , typename ValueT , typename Predicate >
constexpr auto search_n (ForwardIt first, ForwardIt last, Size count, ValueT const &value, Predicate pred) -> ForwardIt
 Searches the range [first, last) for the first sequence of count identical elements, each equal to the given value.
 
template<typename ForwardIt , typename Size , typename ValueT >
constexpr auto search_n (ForwardIt first, ForwardIt last, Size count, ValueT const &value) -> ForwardIt
 Searches the range [first, last) for the first sequence of count identical elements, each equal to the given value.
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt , typename Compare >
constexpr auto set_difference (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination, Compare comp) -> OutputIt
 Copies the elements from the sorted range [first1, last1) which are not found in the sorted range [first2, last2) to the range beginning at destination. Elements are compared using the given binary comparison function comp and the ranges must be sorted with respect to the same.
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt >
constexpr auto set_difference (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination) -> OutputIt
 Copies the elements from the sorted range [first1, last1) which are not found in the sorted range [first2, last2) to the range beginning at destination. Elements are compared using the given binary comparison function comp and the ranges must be sorted with respect to the same.
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt , typename Compare >
constexpr auto set_intersection (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt dest, Compare comp) -> OutputIt
 Constructs a sorted range beginning at dest consisting of elements that are found in both sorted ranges [first1, last1) and [first2, last2). If some element is found m times in [first1, last1) and n times in [first2, last2), the first min(m, n) elements will be copied from the first range to the destination range. The order of equivalent elements is preserved. The resulting range cannot overlap with either of the input ranges.
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt >
constexpr auto set_intersection (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt dest) -> OutputIt
 Constructs a sorted range beginning at dest consisting of elements that are found in both sorted ranges [first1, last1) and [first2, last2). If some element is found m times in [first1, last1) and n times in [first2, last2), the first min(m, n) elements will be copied from the first range to the destination range. The order of equivalent elements is preserved. The resulting range cannot overlap with either of the input ranges.
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt , typename Compare >
constexpr auto set_symmetric_difference (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination, Compare comp) -> OutputIt
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt >
constexpr auto set_symmetric_difference (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt dest) -> OutputIt
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt , typename Compare >
constexpr auto set_union (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination, Compare comp) -> OutputIt
 Constructs a sorted union beginning at destination consisting of the set of elements present in one or both sorted ranges [first1, last1) and [first2, last2). The resulting range cannot overlap with either of the input ranges.
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt >
constexpr auto set_union (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination) -> OutputIt
 Constructs a sorted union beginning at destination consisting of the set of elements present in one or both sorted ranges [first1, last1) and [first2, last2). The resulting range cannot overlap with either of the input ranges.
 
template<typename RandomIt , typename Compare >
constexpr auto sort (RandomIt first, RandomIt last, Compare comp) -> void
 
template<typename RandomIt >
constexpr auto sort (RandomIt first, RandomIt last) -> void
 
template<typename RandomIt , typename Compare >
constexpr auto stable_sort (RandomIt first, RandomIt last, Compare comp) -> void
 
template<typename RandomIt >
constexpr auto stable_sort (RandomIt first, RandomIt last) -> void
 
template<typename InputIt , typename OutputIt , typename UnaryOp >
constexpr auto transform (InputIt first, InputIt last, OutputIt dest, UnaryOp op) -> OutputIt
 
template<typename InputIt1 , typename InputIt2 , typename OutputIt , typename BinaryOp >
constexpr auto transform (InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt dest, BinaryOp op) -> OutputIt
 
template<typename ForwardIt , typename Predicate >
constexpr auto unique (ForwardIt first, ForwardIt last, Predicate pred) -> ForwardIt
 
template<typename ForwardIt >
constexpr auto unique (ForwardIt first, ForwardIt last) -> ForwardIt
 
template<typename InputIt , typename OutputIt , typename Predicate >
constexpr auto unique_copy (InputIt first, InputIt last, OutputIt destination, Predicate pred) -> OutputIt
 
template<typename InputIt , typename OutputIt >
constexpr auto unique_copy (InputIt first, InputIt last, OutputIt destination) -> OutputIt
 
template<typename ForwardIt , typename T , typename Compare >
constexpr auto upper_bound (ForwardIt first, ForwardIt last, T const &value, Compare comp) -> ForwardIt
 
template<typename ForwardIt , typename T >
constexpr auto upper_bound (ForwardIt first, ForwardIt last, T const &value) -> ForwardIt
 

Detailed Description

Algorithms that operate on ranges.

Function Documentation

◆ adjacent_find() [1/2]

template<typename ForwardIt >
constexpr auto adjacent_find ( ForwardIt  first,
ForwardIt  last 
) -> ForwardIt
constexpr

Searches the range [first, last) for two consecutive equal elements. Elements are compared using the given binary predicate p.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
predBinary predicate which returns ​true if the elements should be treated as equal.

https://en.cppreference.com/w/cpp/algorithm/adjacent_find

◆ adjacent_find() [2/2]

constexpr auto adjacent_find ( ForwardIt  first,
ForwardIt  last,
Predicate  pred 
) -> ForwardIt
constexpr

Searches the range [first, last) for two consecutive equal elements. Elements are compared using the given binary predicate p.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
predBinary predicate which returns ​true if the elements should be treated as equal.

https://en.cppreference.com/w/cpp/algorithm/adjacent_find

◆ all_of()

constexpr auto all_of ( InputIt  first,
InputIt  last,
Predicate  p 
) -> bool
constexpr

Checks if unary predicate p returns true for all elements in the range [first, last).

Examples
array.cpp.

◆ any_of()

constexpr auto any_of ( InputIt  first,
InputIt  last,
Predicate  p 
) -> bool
constexpr

Checks if unary predicate p returns true for at least one element in the range [first, last).

◆ binary_search() [1/2]

template<typename ForwardIt , typename T >
constexpr auto binary_search ( ForwardIt  first,
ForwardIt  last,
T const value 
) -> bool
constexpr

Checks if an element equivalent to value appears within the range [first, last). For binary_search to succeed, the range [first, last) must be at least partially ordered with respect to value.

https://en.cppreference.com/w/cpp/algorithm/binary_search

◆ binary_search() [2/2]

constexpr auto binary_search ( ForwardIt  first,
ForwardIt  last,
T const value,
Compare  comp 
) -> bool
constexpr

Checks if an element equivalent to value appears within the range [first, last). For binary_search to succeed, the range [first, last) must be at least partially ordered with respect to value.

https://en.cppreference.com/w/cpp/algorithm/binary_search

◆ bubble_sort() [1/2]

template<typename RandomIt >
constexpr auto bubble_sort ( RandomIt  first,
RandomIt  last 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is guaranteed to be preserved.

https://en.wikipedia.org/wiki/Bubble_sort

Note
Non-standard extension

◆ bubble_sort() [2/2]

constexpr auto bubble_sort ( RandomIt  first,
RandomIt  last,
Compare  comp 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is guaranteed to be preserved.

https://en.wikipedia.org/wiki/Bubble_sort

Note
Non-standard extension

◆ clamp() [1/2]

template<typename Type >
constexpr auto clamp ( Type const v,
Type const lo,
Type const hi 
) -> Type const&
constexprnoexcept

If v compares less than lo, returns lo; otherwise if hi compares less than v, returns hi; otherwise returns v. Uses operator< to compare the values.

◆ clamp() [2/2]

template<typename Type , typename Compare >
constexpr auto clamp ( Type const v,
Type const lo,
Type const hi,
Compare  comp 
) -> Type const&
constexpr

If v compares less than lo, returns lo; otherwise if hi compares less than v, returns hi; otherwise returns v. Uses operator< to compare the values.

◆ copy()

constexpr auto copy ( InputIt  first,
InputIt  last,
OutputIt  destination 
) -> OutputIt
constexpr

Copies the elements in the range, defined by [first, last), to another range beginning at destination.

Copies all elements in the range [first, last) starting from first and proceeding to last - 1. The behavior is undefined if destination is within the range [first, last). In this case, copy_backward may be used instead.

Returns
Output iterator to the element in the destination range, one past the last element copied.
Examples
array.cpp.

◆ copy_backward()

constexpr auto copy_backward ( BidirIt1  first,
BidirIt1  last,
BidirIt2  dLast 
) -> BidirIt2
constexpr

Copies the elements from the range, defined by [first, last), to another range ending at dLast. The elements are copied in reverse order (the last element is copied first), but their relative order is preserved.

The behavior is undefined if dLast is within (first, last]. copy must be used instead of copy_backward in that case.

Returns
Iterator to the last element copied.

◆ copy_if()

constexpr auto copy_if ( InIt  first,
InIt  last,
OutIt  dFirst,
Pred  pred 
) -> OutIt
constexpr

Copies the elements in the range, defined by [first, last), to another range beginning at destination.

Only copies the elements for which the predicate pred returns true. The relative order of the elements that are copied is preserved. The behavior is undefined if the source and the destination ranges overlap.

Returns
Output iterator to the element in the destination range, one past the last element copied.

◆ copy_n()

constexpr auto copy_n ( InputIt  first,
Size  count,
OutputIt  result 
) -> OutputIt
constexpr

Copies exactly count values from the range beginning at first to the range beginning at result. Formally, for each integer 0 <= i < count, performs *(result + i) = *(first + i). Overlap of ranges is formally permitted, but leads to unpredictable ordering of the results.

Returns
Iterator in the destination range, pointing past the last element copied if count>0 or result otherwise.

◆ count()

template<typename InputIt , typename T >
constexpr auto count ( InputIt  first,
InputIt  last,
T const value 
) -> typename iterator_traits<InputIt>::difference_type
constexpr

Returns the number of elements in the range [first, last) satisfying specific criteria. Counts the elements that are equal to value.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
valueThe value to search for.

https://en.cppreference.com/w/cpp/algorithm/count

◆ count_if()

constexpr auto count_if ( InputIt  first,
InputIt  last,
Predicate  p 
) -> typename iterator_traits<InputIt>::difference_type
constexpr

Returns the number of elements in the range [first, last) satisfying specific criteria. Counts elements for which predicate p returns true.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
pUnary predicate which returns ​true for the required elements.

https://en.cppreference.com/w/cpp/algorithm/count

◆ equal() [1/4]

constexpr auto equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2 
) -> bool
constexpr

◆ equal() [2/4]

constexpr auto equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2 
) -> bool
constexpr

◆ equal() [3/4]

constexpr auto equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
Predicate  p 
) -> bool
constexpr

◆ equal() [4/4]

constexpr auto equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
Predicate  p 
) -> bool
constexpr

Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1)), and false otherwise.

◆ equal_range() [1/2]

template<typename ForwardIt , typename T >
constexpr auto equal_range ( ForwardIt  first,
ForwardIt  last,
T const value 
) -> pair<ForwardIt, ForwardIt>
constexpr

◆ equal_range() [2/2]

constexpr auto equal_range ( ForwardIt  first,
ForwardIt  last,
T const value,
Compare  comp 
) -> pair<ForwardIt, ForwardIt>
constexpr

Returns a range containing all elements equivalent to value in the range [first, last).

https://en.cppreference.com/w/cpp/algorithm/equal_range

◆ exchange_sort() [1/2]

template<typename RandomIt >
constexpr auto exchange_sort ( RandomIt  first,
RandomIt  last 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order.

https://en.wikipedia.org/wiki/Sorting_algorithm#Exchange_sort

Note
Non-standard extension

◆ exchange_sort() [2/2]

constexpr auto exchange_sort ( RandomIt  first,
RandomIt  last,
Compare  comp 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order.

https://en.wikipedia.org/wiki/Sorting_algorithm#Exchange_sort

Note
Non-standard extension

◆ fill()

template<typename ForwardIt , typename T >
constexpr auto fill ( ForwardIt  first,
ForwardIt  last,
T const value 
) -> void
constexpr

Assigns the given value to the elements in the range [first, last).

◆ fill_n()

constexpr auto fill_n ( OutputIt  first,
Size  count,
T const value 
) -> OutputIt
constexpr

Assigns the given value to the first count elements in the range beginning at first if count > 0. Does nothing otherwise.

Returns
Iterator one past the last element assigned if count > 0, first otherwise.

◆ find()

template<typename InputIt , typename T >
constexpr auto find ( InputIt  first,
InputIt  last,
T const value 
) -> InputIt
constexprnoexcept

Searches for an element equal to value.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
valueValue to compare the elements to.

https://en.cppreference.com/w/cpp/algorithm/find

Examples
algorithm.cpp.

◆ find_end() [1/2]

constexpr auto find_end ( ForwardIt1  first,
ForwardIt1  last,
ForwardIt2  sFirst,
ForwardIt2  sLast 
) -> ForwardIt1
constexpr

◆ find_end() [2/2]

constexpr auto find_end ( ForwardIt1  first,
ForwardIt1  last,
ForwardIt2  sFirst,
ForwardIt2  sLast,
Predicate  p 
) -> ForwardIt1
constexpr

Searches for the last occurrence of the sequence [sFirst, sLast) in the range [first, last). Elements are compared using the given binary predicate p.

Parameters
firstThe range of elements to examine
lastThe range of elements to examine
sFirstThe range of elements to search for
sLastThe range of elements to search for
pBinary predicate
Returns
Iterator to the beginning of last occurrence of the sequence [sFirst, sLast) in range [first, last). If [sFirst, sLast) is empty or if no such sequence is found, last is returned.

◆ find_first_of() [1/2]

constexpr auto find_first_of ( InputIt  first,
InputIt  last,
ForwardIt  sFirst,
ForwardIt  sLast 
) -> InputIt
constexpr

Searches the range [first, last) for any of the elements in the range [sFirst, sLast).

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
sFirstThe range of elements to search for.
sLastThe range of elements to search for.

https://en.cppreference.com/w/cpp/algorithm/find_first_of

◆ find_first_of() [2/2]

constexpr auto find_first_of ( InputIt  first,
InputIt  last,
ForwardIt  sFirst,
ForwardIt  sLast,
Predicate  pred 
) -> InputIt
constexpr

Searches the range [first, last) for any of the elements in the range [sFirst, sLast). Elements are compared using the given binary predicate pred.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
sFirstThe range of elements to search for.
sLastThe range of elements to search for.
predPredicate which returns ​true if the elements should be treated as equal.

https://en.cppreference.com/w/cpp/algorithm/find_first_of

◆ find_if()

constexpr auto find_if ( InputIt  first,
InputIt  last,
Predicate  pred 
) -> InputIt
constexprnoexcept

Searches for an element for which predicate p returns true.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
predUnary predicate which returns ​true for the required element.

https://en.cppreference.com/w/cpp/algorithm/find

◆ find_if_not()

constexpr auto find_if_not ( InputIt  first,
InputIt  last,
Predicate  pred 
) -> InputIt
constexprnoexcept

Searches for an element for which predicate q returns false.

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
predUnary predicate which returns ​true for the required element.

https://en.cppreference.com/w/cpp/algorithm/find

◆ for_each()

constexpr auto for_each ( InputIt  first,
InputIt  last,
UnaryFunc  f 
) -> UnaryFunc
constexprnoexcept

Applies the given function object f to the result of dereferencing every iterator in the range [first, last) in order.

Parameters
firstThe range to apply the function to.
lastThe range to apply the function to.
fFunction object, to be applied to the result of dereferencing every iterator in the range.

https://en.cppreference.com/w/cpp/algorithm/for_each

Examples
set.cpp.

◆ for_each_n()

constexpr auto for_each_n ( InputIt  first,
Size  n,
UnaryFunc  f 
) -> InputIt
constexprnoexcept

Applies the given function object f to the result of dereferencing every iterator in the range [first, first + n] in order.

Parameters
firstThe beginning of the range to apply the function to.
nThe number of elements to apply the function to.
fFunction object, to be applied to the result of dereferencing every iterator in the range.

https://en.cppreference.com/w/cpp/algorithm/for_each_n

◆ generate()

constexpr auto generate ( ForwardIt  first,
ForwardIt  last,
Generator  g 
) -> void
constexpr

Assigns each element in range [first, last) a value generated by the given function object g.

Parameters
firstThe range of elements to generate.
lastThe range of elements to generate.
gGenerator function object that will be called.

https://en.cppreference.com/w/cpp/algorithm/generate

◆ generate_n()

constexpr auto generate_n ( OutputIt  first,
SizeT  count,
Generator  g 
) -> OutputIt
constexpr

Assigns values, generated by given function object g, to the first count elements in the range beginning at first, if count > 0. Does nothing otherwise.

Parameters
firstThe range of elements to generate.
countNumber of the elements to generate.
gGenerator function object that will be called.

https://en.cppreference.com/w/cpp/algorithm/generate_n

◆ gnome_sort() [1/2]

template<typename BidirIt >
constexpr auto gnome_sort ( BidirIt  first,
BidirIt  last 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order.

https://en.wikipedia.org/wiki/Gnome_sort

Note
Non-standard extension

◆ gnome_sort() [2/2]

constexpr auto gnome_sort ( BidirIt  first,
BidirIt  last,
Compare  comp 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order.

https://en.wikipedia.org/wiki/Gnome_sort

Note
Non-standard extension

◆ includes() [1/2]

constexpr auto includes ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2 
) -> bool
constexpr

◆ includes() [2/2]

constexpr auto includes ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
Compare  comp 
) -> bool
constexpr

Returns true if the sorted range [first2, last2) is a subsequence of the sorted range [first1, last1). Both ranges must be sorted.

◆ inplace_merge() [1/2]

constexpr auto inplace_merge ( BidirIt  begin,
BidirIt  mid,
BidirIt  end,
Compare  comp 
) -> void
constexpr

Merges two consecutive sorted ranges [first, middle) and [middle, last) into one sorted range [first, last).

A sequence [first, last) is said to be sorted with respect to a comparator comp if for any iterator it pointing to the sequence and any non-negative integer n such that it + n is a valid iterator pointing to an element of the sequence, comp(*(it + n), *it) evaluates to false.

https://en.cppreference.com/w/cpp/algorithm/inplace_merge

◆ inplace_merge() [2/2]

template<typename BidirIt >
constexpr auto inplace_merge ( BidirIt  first,
BidirIt  mid,
BidirIt  last 
) -> void
constexpr

◆ insertion_sort() [1/2]

template<typename RandomIt >
constexpr auto insertion_sort ( RandomIt  first,
RandomIt  last 
) -> void
constexpr
Note
Non-standard extension

◆ insertion_sort() [2/2]

constexpr auto insertion_sort ( RandomIt  first,
RandomIt  last,
Compare  comp 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is guaranteed to be preserved.

https://en.wikipedia.org/wiki/Insertion_sort

Note
Non-standard extension

◆ is_partitioned()

constexpr auto is_partitioned ( InputIt  first,
InputIt  last,
Predicate  p 
) -> bool
constexpr

Returns true if all elements in the range [first, last) that satisfy the predicate p appear before all elements that don't. Also returns true if the range is empty.

https://en.cppreference.com/w/cpp/algorithm/is_partitioned

◆ is_permutation() [1/2]

constexpr auto is_permutation ( ForwardIt1  first,
ForwardIt1  last,
ForwardIt2  first2 
) -> bool
constexpr

Returns true if there exists a permutation of the elements in the range [first1, last1) that makes that range equal to the range [first2, last2), where last2 denotes first2 + (last1 - first1) if it was not given.

◆ is_permutation() [2/2]

constexpr auto is_permutation ( ForwardIt1  first1,
ForwardIt1  last1,
ForwardIt2  first2,
ForwardIt2  last2 
) -> bool
constexpr

◆ is_sorted() [1/2]

template<typename ForwardIt >
constexpr auto is_sorted ( ForwardIt  first,
ForwardIt  last 
) -> bool
constexpr

Checks if the elements in range [first, last) are sorted in non-descending order.

◆ is_sorted() [2/2]

constexpr auto is_sorted ( ForwardIt  first,
ForwardIt  last,
Compare  comp 
) -> bool
constexpr

◆ is_sorted_until() [1/2]

template<typename ForwardIt >
constexpr auto is_sorted_until ( ForwardIt  first,
ForwardIt  last 
) -> ForwardIt
constexpr

Examines the range [first, last) and finds the largest range beginning at first in which the elements are sorted in non-descending order.

◆ is_sorted_until() [2/2]

constexpr auto is_sorted_until ( ForwardIt  first,
ForwardIt  last,
Compare  comp 
) -> ForwardIt
constexpr

◆ iter_swap()

constexpr auto iter_swap ( ForwardIt1  a,
ForwardIt2  b 
) -> void
constexpr

Swaps the values of the elements the given iterators are pointing to.

Parameters
aIterators to the elements to swap.
bIterators to the elements to swap.

https://en.cppreference.com/w/cpp/algorithm/iter_swap

◆ lexicographical_compare() [1/2]

constexpr auto lexicographical_compare ( InputIt1  f1,
InputIt1  l1,
InputIt2  f2,
InputIt2  l2 
) -> bool
constexpr

◆ lexicographical_compare() [2/2]

constexpr auto lexicographical_compare ( InputIt1  f1,
InputIt1  l1,
InputIt2  f2,
InputIt2  l2,
Compare  comp 
) -> bool
constexpr

Checks if the first range [f1, l1) is lexicographically less than the second range [f2, l2).

https://en.cppreference.com/w/cpp/algorithm/lexicographical_compare

◆ lower_bound() [1/2]

template<typename ForwardIt , typename T >
constexpr auto lower_bound ( ForwardIt  first,
ForwardIt  last,
T const value 
) -> ForwardIt
constexprnoexcept

◆ lower_bound() [2/2]

constexpr auto lower_bound ( ForwardIt  first,
ForwardIt  last,
T const value,
Compare  comp 
) -> ForwardIt
constexprnoexcept

Returns an iterator pointing to the first element in the range [first, last) that is not less than (i.e. greater or equal to) value, or last if no such element is found.

https://en.cppreference.com/w/cpp/algorithm/lower_bound

◆ max() [1/2]

template<typename Type >
constexpr auto max ( Type const a,
Type const b 
) -> Type const&
constexprnoexcept

Returns the greater of a and b.

◆ max() [2/2]

template<typename Type , typename Compare >
constexpr auto max ( Type const a,
Type const b,
Compare  comp 
) -> Type const&
constexprnoexcept

Returns the greater of a and b, using a compare function.

◆ max_element() [1/2]

template<typename ForwardIt >
constexpr auto max_element ( ForwardIt  first,
ForwardIt  last 
) -> ForwardIt
constexprnoexcept

Finds the greatest element in the range [first, last). Elements are compared using operator<.

◆ max_element() [2/2]

constexpr auto max_element ( ForwardIt  first,
ForwardIt  last,
Compare  comp 
) -> ForwardIt
constexpr

Finds the greatest element in the range [first, last). Elements are compared using the given binary comparison function comp.

◆ merge() [1/2]

constexpr auto merge ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  destination 
) -> OutputIt
constexpr

◆ merge() [2/2]

constexpr auto merge ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  destination,
Compare  comp 
) -> OutputIt
constexpr

Merges two sorted ranges [first1, last1) and [first2, last2) into one sorted range beginning at destination.

◆ merge_sort() [1/2]

template<typename BidirIt >
constexpr auto merge_sort ( BidirIt  first,
BidirIt  last 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order.

https://en.wikipedia.org/wiki/Merge_sort

Note
Non-standard extension

◆ merge_sort() [2/2]

constexpr auto merge_sort ( BidirIt  first,
BidirIt  last,
Compare  comp 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order.

https://en.wikipedia.org/wiki/Merge_sort

Note
Non-standard extension

◆ min() [1/2]

template<typename Type >
constexpr auto min ( Type const a,
Type const b 
) -> Type const&
constexprnoexcept

Returns the smaller of a and b.

◆ min() [2/2]

template<typename Type , typename Compare >
constexpr auto min ( Type const a,
Type const b,
Compare  comp 
) -> Type const&
constexprnoexcept

Returns the smaller of a and b, using a compare function.

◆ min_element() [1/2]

template<typename ForwardIt >
constexpr auto min_element ( ForwardIt  first,
ForwardIt  last 
) -> ForwardIt
constexprnoexcept

Finds the smallest element in the range [first, last). Elements are compared using operator<.

◆ min_element() [2/2]

constexpr auto min_element ( ForwardIt  first,
ForwardIt  last,
Compare  comp 
) -> ForwardIt
constexpr

Finds the smallest element in the range [first, last). Elements are compared using the given binary comparison function comp.

◆ minmax() [1/2]

template<typename T >
constexpr auto minmax ( T const a,
T const b 
) -> pair<T const&, T const&>
constexpr

Returns the lowest and the greatest of the given values.

◆ minmax() [2/2]

template<typename T , typename Compare >
constexpr auto minmax ( T const a,
T const b,
Compare  comp 
) -> pair<T const&, T const&>
constexpr

Returns the lowest and the greatest of the given values.

◆ minmax_element() [1/2]

template<typename ForwardIt >
constexpr auto minmax_element ( ForwardIt  first,
ForwardIt  last 
) -> pair<ForwardIt, ForwardIt>
constexpr

Finds the smallest and greatest element in the range [first, last).

◆ minmax_element() [2/2]

constexpr auto minmax_element ( ForwardIt  first,
ForwardIt  last,
Compare  comp 
) -> pair<ForwardIt, ForwardIt>
constexpr

Finds the smallest and greatest element in the range [first, last).

◆ mismatch()

constexpr auto mismatch ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
Predicate  pred 
) -> pair<InputIt1, InputIt2>
constexpr

Returns the first mismatching pair of elements from two ranges: one defined by [first1, last1) and another defined by [first2,last2). If last2 is not provided (overloads (1-4)), it denotes first2 + (last1 - first1). Elements are compared using the given binary predicate pred.

Parameters
first1The first range of the elements.
last1The first range of the elements.
first2The second range of the elements.
predBinary predicate which returns ​true if the elements should be treated as equal.

https://en.cppreference.com/w/cpp/algorithm/mismatch

◆ move()

constexpr auto move ( InputIt  first,
InputIt  last,
OutputIt  destination 
) -> OutputIt
constexpr

Moves the elements in the range [first, last), to another range beginning at destination, starting from first and proceeding to last - 1. After this operation the elements in the moved-from range will still contain valid values of the appropriate type, but not necessarily the same values as before the move.

https://en.cppreference.com/w/cpp/algorithm/move

Returns
Output iterator to the element past the last element moved.
Parameters
firstThe range of elements to move.
lastThe range of elements to move.
destinationThe beginning of the destination range.
Examples
optional.cpp.

◆ move_backward()

constexpr auto move_backward ( BidirIt1  first,
BidirIt1  last,
BidirIt2  destination 
) -> BidirIt2
constexpr

Moves the elements from the range [first, last), to another range ending at destination. The elements are moved in reverse order (the last element is moved first), but their relative order is preserved.

https://en.cppreference.com/w/cpp/algorithm/move_backward

Returns
Iterator in the destination range, pointing at the last element moved.
Parameters
firstThe range of elements to move.
lastThe range of elements to move.
destinationEnd of the destination range.

◆ none_of()

constexpr auto none_of ( InputIt  first,
InputIt  last,
Predicate  p 
) -> bool
constexpr

Checks if unary predicate p returns true for no elements in the range [first, last).

◆ nth_element()

constexpr auto nth_element ( RandomIt  first,
RandomIt  nth,
RandomIt  last,
Compare  comp 
) -> void
constexpr

nth_element is a partial sorting algorithm that rearranges elements in [first, last) such that:

  • The element pointed at by nth is changed to whatever element would occur in that position if [first, last) were sorted.
  • All of the elements before this new nth element are less than or equal to the elements after the new nth element.

https://en.cppreference.com/w/cpp/algorithm/nth_element

◆ partial_sort()

constexpr auto partial_sort ( RandomIt  first,
RandomIt  middle,
RandomIt  last,
Compare  comp 
) -> void
constexpr

Rearranges elements such that the range [first, middle) contains the sorted middle - first smallest elements in the range [first, last). The order of equal elements is not guaranteed to be preserved. The order of the remaining elements in the range [middle, last) is unspecified.

https://en.cppreference.com/w/cpp/algorithm/partial_sort

◆ partition()

constexpr auto partition ( ForwardIt  first,
ForwardIt  last,
Predicate  p 
) -> ForwardIt
constexpr

Reorders the elements in the range [first, last) in such a way that all elements for which the predicate p returns true precede the elements for which predicate p returns false. Relative order of the elements is not preserved.

◆ partition_copy()

constexpr auto partition_copy ( InputIt  first,
InputIt  last,
OutputIt1  destinationTrue,
OutputIt2  destinationFalse,
Predicate  p 
) -> pair<OutputIt1, OutputIt2>
constexpr

Copies the elements from the range [first, last) to two different ranges depending on the value returned by the predicate p. The elements that satisfy the predicate p are copied to the range beginning at destination_true. The rest of the elements are copied to the range beginning at destination_false.

The behavior is undefined if the input range overlaps either of the output ranges.

◆ partition_point()

constexpr auto partition_point ( ForwardIt  first,
ForwardIt  last,
Predicate  p 
) -> ForwardIt
constexpr

Examines the partitioned (as if by partition) range [first, last) and locates the end of the first partition, that is, the first element that does not satisfy p or last if all elements satisfy p.

◆ remove()

template<typename ForwardIt , typename T >
constexpr auto remove ( ForwardIt  first,
ForwardIt  last,
T const value 
) -> ForwardIt
constexpr

Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range.

◆ remove_copy()

constexpr auto remove_copy ( InputIt  first,
InputIt  last,
OutputIt  destination,
T const value 
) -> OutputIt
constexpr

Copies elements from the range [first, last), to another range beginning at destination, omitting the elements which satisfy specific criteria. Source and destination ranges cannot overlap. Ignores all elements that are equal to value.

Returns
Iterator to the element past the last element copied.

◆ remove_copy_if()

constexpr auto remove_copy_if ( InputIt  first,
InputIt  last,
OutputIt  destination,
Predicate  p 
) -> OutputIt
constexpr

Copies elements from the range [first, last), to another range beginning at destination, omitting the elements which satisfy specific criteria. Source and destination ranges cannot overlap. Ignores all elements for which predicate p returns true.

Returns
Iterator to the element past the last element copied.

◆ remove_if()

constexpr auto remove_if ( ForwardIt  first,
ForwardIt  last,
Predicate  pred 
) -> ForwardIt
constexpr

Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range.

◆ replace()

template<typename ForwardIt , typename T >
constexpr auto replace ( ForwardIt  first,
ForwardIt  last,
T const oldValue,
T const newValue 
) -> void
constexpr

Replaces all elements satisfying specific criteria with new_value in the range [first, last). Replaces all elements that are equal to old_value.

◆ replace_if()

constexpr auto replace_if ( ForwardIt  first,
ForwardIt  last,
Predicate  p,
T const newValue 
) -> void
constexpr

Replaces all elements satisfying specific criteria with new_value in the range [first, last). Replaces all elements for which predicate p returns true.

◆ reverse()

template<typename BidirIt >
constexpr auto reverse ( BidirIt  first,
BidirIt  last 
) -> void
constexpr

Reverses the order of the elements in the range [first, last).

◆ reverse_copy()

constexpr auto reverse_copy ( BidirIt  first,
BidirIt  last,
OutputIt  destination 
) -> OutputIt
constexpr

Copies the elements from the range [first, last) to another range beginning at d_first in such a way that the elements in the new range are in reverse order.

If the source and destination ranges (that is, [first, last) and [d_first, d_first+(last-first)) respectively) overlap, the behavior is undefined.

◆ rotate()

template<typename ForwardIt >
constexpr auto rotate ( ForwardIt  first,
ForwardIt  nFirst,
ForwardIt  last 
) -> ForwardIt
constexpr

Performs a left rotation on a range of elements.

Specifically, rotate swaps the elements in the range [first, last) in such a way that the element n_first becomes the first element of the new range and n_first - 1 becomes the last element. A precondition of this function is that [first, n_first) and [n_first, last) are valid ranges.

◆ rotate_copy()

constexpr auto rotate_copy ( ForwardIt  first,
ForwardIt  nFirst,
ForwardIt  last,
OutputIt  destination 
) -> OutputIt
constexpr

Copies the elements from the range [first, last), to another range beginning at destination in such a way, that the element nFirst becomes the first element of the new range and nFirst - 1 becomes the last element.

◆ search() [1/3]

constexpr auto search ( FwdIt  first,
FwdIt  last,
Searcher const searcher 
) -> FwdIt
constexpr

Searches for the first occurrence of the sequence of elements [sFirst, sLast) in the range [first, last).

https://en.cppreference.com/w/cpp/algorithm/search

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
sFirstThe range of elements to search for.
sLastThe range of elements to search for.
predBinary predicate which returns ​true if the elements should be treated as equal.

◆ search() [2/3]

constexpr auto search ( FwdIt1  first,
FwdIt1  last,
FwdIt2  sFirst,
FwdIt2  sLast 
) -> FwdIt1
constexpr

Searches for the first occurrence of the sequence of elements [sFirst, sLast) in the range [first, last).

https://en.cppreference.com/w/cpp/algorithm/search

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
sFirstThe range of elements to search for.
sLastThe range of elements to search for.
predBinary predicate which returns ​true if the elements should be treated as equal.

◆ search() [3/3]

constexpr auto search ( FwdIt1  first,
FwdIt1  last,
FwdIt2  sFirst,
FwdIt2  sLast,
Predicate  pred 
) -> FwdIt1
constexpr

Searches for the first occurrence of the sequence of elements [sFirst, sLast) in the range [first, last).

https://en.cppreference.com/w/cpp/algorithm/search

Parameters
firstThe range of elements to examine.
lastThe range of elements to examine.
sFirstThe range of elements to search for.
sLastThe range of elements to search for.
predBinary predicate which returns ​true if the elements should be treated as equal.

◆ search_n() [1/2]

constexpr auto search_n ( ForwardIt  first,
ForwardIt  last,
Size  count,
ValueT const value 
) -> ForwardIt
constexpr

Searches the range [first, last) for the first sequence of count identical elements, each equal to the given value.

◆ search_n() [2/2]

constexpr auto search_n ( ForwardIt  first,
ForwardIt  last,
Size  count,
ValueT const value,
Predicate  pred 
) -> ForwardIt
constexpr

Searches the range [first, last) for the first sequence of count identical elements, each equal to the given value.

◆ set_difference() [1/2]

constexpr auto set_difference ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  destination 
) -> OutputIt
constexpr

Copies the elements from the sorted range [first1, last1) which are not found in the sorted range [first2, last2) to the range beginning at destination. Elements are compared using the given binary comparison function comp and the ranges must be sorted with respect to the same.

◆ set_difference() [2/2]

constexpr auto set_difference ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  destination,
Compare  comp 
) -> OutputIt
constexpr

Copies the elements from the sorted range [first1, last1) which are not found in the sorted range [first2, last2) to the range beginning at destination. Elements are compared using the given binary comparison function comp and the ranges must be sorted with respect to the same.

◆ set_intersection() [1/2]

constexpr auto set_intersection ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  dest 
) -> OutputIt
constexpr

Constructs a sorted range beginning at dest consisting of elements that are found in both sorted ranges [first1, last1) and [first2, last2). If some element is found m times in [first1, last1) and n times in [first2, last2), the first min(m, n) elements will be copied from the first range to the destination range. The order of equivalent elements is preserved. The resulting range cannot overlap with either of the input ranges.

◆ set_intersection() [2/2]

constexpr auto set_intersection ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  dest,
Compare  comp 
) -> OutputIt
constexpr

Constructs a sorted range beginning at dest consisting of elements that are found in both sorted ranges [first1, last1) and [first2, last2). If some element is found m times in [first1, last1) and n times in [first2, last2), the first min(m, n) elements will be copied from the first range to the destination range. The order of equivalent elements is preserved. The resulting range cannot overlap with either of the input ranges.

◆ set_symmetric_difference() [1/2]

constexpr auto set_symmetric_difference ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  dest 
) -> OutputIt
constexpr

Computes symmetric difference of two sorted ranges: the elements that are found in either of the ranges, but not in both of them are copied to the range beginning at destination. The resulting range is also sorted.

◆ set_symmetric_difference() [2/2]

constexpr auto set_symmetric_difference ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  destination,
Compare  comp 
) -> OutputIt
constexpr

Computes symmetric difference of two sorted ranges: the elements that are found in either of the ranges, but not in both of them are copied to the range beginning at destination. The resulting range is also sorted.

◆ set_union() [1/2]

constexpr auto set_union ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  destination 
) -> OutputIt
constexpr

Constructs a sorted union beginning at destination consisting of the set of elements present in one or both sorted ranges [first1, last1) and [first2, last2). The resulting range cannot overlap with either of the input ranges.

◆ set_union() [2/2]

constexpr auto set_union ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
OutputIt  destination,
Compare  comp 
) -> OutputIt
constexpr

Constructs a sorted union beginning at destination consisting of the set of elements present in one or both sorted ranges [first1, last1) and [first2, last2). The resulting range cannot overlap with either of the input ranges.

◆ shift_left()

template<typename ForwardIt >
constexpr auto shift_left ( ForwardIt  first,
ForwardIt const  last,
typename iterator_traits< ForwardIt >::difference_type  n 
) -> ForwardIt
constexpr

Shifts the elements in the range [first, last) by n positions.

Shifts the elements towards the beginning of the range. If n == 0 or n >= last - first, there are no effects. If n < 0, the behavior is undefined. Otherwise, for every integer i in [0, last - first - n), moves the element originally at position first + n + i to position first + i. The moves are performed in increasing order of i starting from ​0​.

◆ shift_right()

template<typename BidiIt >
constexpr auto shift_right ( BidiIt  first,
BidiIt  last,
typename etl::iterator_traits< BidiIt >::difference_type  n 
) -> BidiIt
constexpr

Shifts the elements in the range [first, last) by n positions.

Shifts the elements towards the end of the range. If n <= 0 or n >= last - first, there are no effects. Otherwise, for every integer i in [0, last - first - n), moves the element originally at position first + i to position first + n + i.

https://en.cppreference.com/w/cpp/algorithm/shift

Note
The standard specifies that this algorithm should also work with legacy forward iterators. I don't know how to implement that without dynamic memory, so forward iterators are not supported.

◆ sort() [1/2]

template<typename RandomIt >
constexpr auto sort ( RandomIt  first,
RandomIt  last 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is not guaranteed to be preserved.

https://en.cppreference.com/w/cpp/algorithm/sort

◆ sort() [2/2]

constexpr auto sort ( RandomIt  first,
RandomIt  last,
Compare  comp 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is not guaranteed to be preserved.

https://en.cppreference.com/w/cpp/algorithm/sort

◆ stable_partition()

constexpr auto stable_partition ( BidirIt  f,
BidirIt  l,
Predicate  p 
) -> BidirIt
constexpr

Reorders the elements in the range [first, last) in such a way that all elements for which the predicate p returns true precede the elements for which predicate p returns false. Relative order of the elements is preserved.

◆ stable_sort() [1/2]

template<typename RandomIt >
constexpr auto stable_sort ( RandomIt  first,
RandomIt  last 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order. The order of equivalent elements is guaranteed to be preserved. Elements are compared using the given comparison function comp.

https://en.cppreference.com/w/cpp/algorithm/stable_sort

◆ stable_sort() [2/2]

constexpr auto stable_sort ( RandomIt  first,
RandomIt  last,
Compare  comp 
) -> void
constexpr

Sorts the elements in the range [first, last) in non-descending order. The order of equivalent elements is guaranteed to be preserved. Elements are compared using the given comparison function comp.

https://en.cppreference.com/w/cpp/algorithm/stable_sort

◆ swap_ranges()

constexpr auto swap_ranges ( ForwardIt1  first1,
ForwardIt1  last1,
ForwardIt2  first2 
) -> ForwardIt2
constexpr

Exchanges elements between range [first1 ,last1) and another range starting at first2.

Parameters
first1The first range of elements to swap.
last1The first range of elements to swap.
first2Beginning of the second range of elements to swap.
Returns
Iterator to the element past the last element exchanged in the range beginning with first2.

https://en.cppreference.com/w/cpp/algorithm/swap_ranges

◆ transform() [1/2]

constexpr auto transform ( InputIt  first,
InputIt  last,
OutputIt  dest,
UnaryOp  op 
) -> OutputIt
constexpr

Applies the given function to a range and stores the result in another range, beginning at dest. The unary operation op is applied to the range defined by [first, last).

https://en.cppreference.com/w/cpp/algorithm/transform

Parameters
firstThe first range of elements to transform.
lastThe first range of elements to transform.
destThe beginning of the destination range, may be equal to first.
opUnary operation function object that will be applied.
Examples
string.cpp, and vector.cpp.

◆ transform() [2/2]

constexpr auto transform ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
OutputIt  dest,
BinaryOp  op 
) -> OutputIt
constexpr

Applies the given function to a range and stores the result in another range, beginning at dest. The unary operation op is applied to the range defined by [first, last).

https://en.cppreference.com/w/cpp/algorithm/transform

Parameters
firstThe first range of elements to transform.
lastThe first range of elements to transform.
destThe beginning of the destination range, may be equal to first.
opUnary operation function object that will be applied.

◆ unique() [1/2]

template<typename ForwardIt >
constexpr auto unique ( ForwardIt  first,
ForwardIt  last 
) -> ForwardIt
constexpr

Eliminates all except the first element from every consecutive group of equivalent elements from the range [first, last) and returns a past-the-end iterator for the new logical end of the range.

◆ unique() [2/2]

constexpr auto unique ( ForwardIt  first,
ForwardIt  last,
Predicate  pred 
) -> ForwardIt
constexpr

Eliminates all except the first element from every consecutive group of equivalent elements from the range [first, last) and returns a past-the-end iterator for the new logical end of the range.

◆ unique_copy() [1/2]

constexpr auto unique_copy ( InputIt  first,
InputIt  last,
OutputIt  destination 
) -> OutputIt
constexpr

Copies the elements from the range [first, last), to another range beginning at d_first in such a way that there are no consecutive equal elements. Only the first element of each group of equal elements is copied.

Elements are compared using the given binary predicate pred. The behavior is undefined if it is not an equivalence relation.

◆ unique_copy() [2/2]

constexpr auto unique_copy ( InputIt  first,
InputIt  last,
OutputIt  destination,
Predicate  pred 
) -> OutputIt
constexpr

Copies the elements from the range [first, last), to another range beginning at d_first in such a way that there are no consecutive equal elements. Only the first element of each group of equal elements is copied.

Elements are compared using the given binary predicate pred. The behavior is undefined if it is not an equivalence relation.

◆ upper_bound() [1/2]

template<typename ForwardIt , typename T >
constexpr auto upper_bound ( ForwardIt  first,
ForwardIt  last,
T const value 
) -> ForwardIt
constexpr

Returns an iterator pointing to the first element in the range [first, last) that is greater than value, or last if no such element is found.

The range [first, last) must be partitioned with respect to the expression not (value < element) or not comp(value, element), i.e., all elements for which the expression is true must precede all elements for which the expression is false. A fully-sorted range meets this criterion.

◆ upper_bound() [2/2]

constexpr auto upper_bound ( ForwardIt  first,
ForwardIt  last,
T const value,
Compare  comp 
) -> ForwardIt
constexpr

Returns an iterator pointing to the first element in the range [first, last) that is greater than value, or last if no such element is found.

The range [first, last) must be partitioned with respect to the expression not (value < element) or not comp(value, element), i.e., all elements for which the expression is true must precede all elements for which the expression is false. A fully-sorted range meets this criterion.