kblib 0.2.3
General utilities library for modern C++
algorithm.h File Reference

Provides general-purpose algorithms, similar to the <algorithms> header. More...

#include "tdecl.h"
#include "iterators.h"
#include "traits.h"
#include <algorithm>
#include <cmath>
#include <tuple>
Include dependency graph for algorithm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kblib::equivalent< Compare, Obj >
 A function object implementing the equivalence relationship over a comparison predicate. More...
 
struct  kblib::equivalent< void, Obj >
 
struct  kblib::equivalent< Compare, void >
 
struct  kblib::equivalent< void, void >
 
struct  kblib::is_optional< T >
 
struct  kblib::is_optional< std::optional< U > >
 

Namespaces

namespace  kblib
 The main namespace in which all entities from kblib are defined.
 
namespace  kblib::detail_algorithm
 

Functions

template<typename Callable >
constexpr auto kblib::repeat (std::size_t N, Callable func) noexcept(noexcept(func())) -> return_assert_t< is_invocable< Callable >::value, void >
 Invoke a function N times. More...
 
template<typename Container , typename Elem >
constexpr auto kblib::erase (Container &c, const Elem &val) noexcept(noexcept(c.erase(std::remove(c.begin(), c.end(), val), c.end()))) -> void
 Abbreviation of the erase-remove idiom as a free function. More...
 
template<typename Container , typename UnaryPredicate >
constexpr auto kblib::erase_if (Container &c, UnaryPredicate p) noexcept(noexcept(c.erase(std::remove_if(c.begin(), c.end(), std::ref(p)), c.end()))) -> void
 Abbreviation of the erase-remove idiom as a free function. More...
 
template<typename Obj >
constexpr auto kblib::equals (const Obj &a, const Obj &b) noexcept(noexcept(a< b)) -> bool
 Synthesize an equivalence relation from <. More...
 
template<typename Obj , typename Compare >
constexpr auto kblib::equals (const Obj &a, const Obj &b, Compare comp) noexcept(noexcept(comp(a, b))) -> bool
 Synthesize an equivalence relation from comp. More...
 
template<typename InputIt , typename T >
constexpr auto kblib::accumulate (InputIt first, InputIt last, T init) -> T
 A constexpr version of std::accumulate. More...
 
template<class InputIt , class T , class BinaryOperation >
constexpr auto kblib::accumulate (InputIt first, InputIt last, T init, BinaryOperation op) -> T
 A constexpr version of std::accumulate. More...
 
template<typename InputIt >
constexpr auto kblib::sum (InputIt first, InputIt last) -> std::decay_t< decltype(*first)>
 Sum a range. More...
 
template<typename InputIt , typename BinaryOperation >
constexpr auto kblib::sum (InputIt first, InputIt last, BinaryOperation op) -> std::decay_t< decltype(*first)>
 Fold a range over an operation. More...
 
template<typename Range >
constexpr auto kblib::sum (Range &&r) -> auto
 Sum a range. More...
 
template<typename InputIt , typename EndIt , typename OutputIt , typename T , typename BinaryAccumulation , typename UnaryTransform >
constexpr auto kblib::transform_exclusive_scan (InputIt first, EndIt last, OutputIt d_first, T init, BinaryAccumulation accum, UnaryTransform proj) -> OutputIt
 
template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find (ForwardIt begin, EndIt end, const Elem &value) noexcept(noexcept(*begin==value)) -> ForwardIt
 Finds a value in range [begin, end). If not found, returns end. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename Elem , typename Comp >
constexpr auto kblib::find (ForwardIt begin, EndIt end, const Elem &value, Comp &&comp) noexcept(noexcept(comp(*begin, value))) -> ForwardIt
 Finds a value in range [begin, end). If not found, returns end. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_if (ForwardIt begin, EndIt end, UnaryPredicate &&pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> ForwardIt
 Finds the first value in range [begin, end) for which pred returns true. If not found, returns end. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_if_not (ForwardIt begin, EndIt end, UnaryPredicate &&pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> ForwardIt
 Finds the first value in range [begin, end) for which pred returns false. If not found, returns end. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find_last (ForwardIt begin, EndIt end, const Elem &value) noexcept(noexcept(*begin==value)) -> ForwardIt
 Searches a range for the last occurence of a match, and returns an iterator to it. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_if (ForwardIt begin, EndIt end, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> ForwardIt
 Searches a range for the last element on which a predicate returns true. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_if_not (ForwardIt begin, EndIt end, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> ForwardIt
 Searches a range for the last element on which a predicate returns false. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find_in (ForwardIt begin, EndIt end, const Elem &value) noexcept(noexcept(*begin==value)) -> size_t
 Find the offset of the first ocurrence of v in a range from the beginning. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_in_if (ForwardIt begin, EndIt end, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> size_t
 Find the offset of the first element for which p returns true. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_in_if_not (ForwardIt begin, EndIt end, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> size_t
 Find the offset of the first element for which p returns false. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find_last_in (ForwardIt begin, EndIt end, const Elem &value) noexcept(noexcept(*begin==value)) -> size_t
 Find the offset of the last ocurrence of v in a range from the beginning. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if (ForwardIt begin, EndIt end, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> size_t
 
template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if_not (ForwardIt begin, EndIt end, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *begin))) -> size_t
 Find the offset of the last element for which p returns false. It also allows for a sentinel end iterator. More...
 
template<typename Container , typename T >
constexpr auto kblib::find_in (const Container &c, const T &value) noexcept(noexcept(*std::declval< iterator_type_for_t< const Container > & >()==value)) -> size_t
 Find the first element in c equal to v and return the position. More...
 
template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_in_if (const Container &c, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *std::declval< iterator_type_for_t< const Container > & >()))) -> size_t
 Find the first element in c for which p returns true and return the position. More...
 
template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_in_if_not (const Container &c, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *std::declval< iterator_type_for_t< const Container > & >()))) -> size_t
 Find the first element in c for which p returns false and return the position. More...
 
template<typename Container , typename T >
constexpr auto kblib::find_last_in (const Container &c, const T &value) noexcept(noexcept(*std::declval< iterator_type_for_t< const Container > & >()==value)) -> size_t
 Find the last element in c equal to v and return the position. More...
 
template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if (const Container &c, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *std::declval< iterator_type_for_t< const Container > & >()))) -> size_t
 Find the last element in c for which p returns true and return the position. More...
 
template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if_not (const Container &c, UnaryPredicate pred) noexcept(noexcept(kblib::invoke(pred, *std::declval< iterator_type_for_t< const Container > & >()))) -> size_t
 Find the last element in c for which p returns true and return the position. More...
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename BinaryPredicate = std::equal_to<>>
constexpr auto kblib::find_match (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, BinaryPredicate cmp) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value and is_invocable< BinaryPredicate, decltype(*begin1), decltype(*begin2)>::value, std::pair< InputIt1, InputIt2 > >
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename EndIt2 , typename BinaryPredicate = std::equal_to<>>
constexpr auto kblib::find_match (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, EndIt2 end2, BinaryPredicate cmp) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value and is_invocable< BinaryPredicate, decltype(*begin1), decltype(*begin2)>::value, std::pair< InputIt1, InputIt2 > >
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename EndIt2 , typename BinaryPred >
constexpr auto kblib::starts_with (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, EndIt2 end2, BinaryPred pred) -> enable_if_t<(is_input_iterator_v< InputIt1 > and is_input_iterator_v< InputIt2 >) and not(is_random_access_iterator_v< InputIt1 > and is_random_access_iterator_v< InputIt2 >), bool >
 Checks if a given range starts with a particular subrange. More...
 
template<typename RandomAccessIt1 , typename RandomAccessIt2 , typename BinaryPred = std::equal_to<>>
constexpr auto kblib::starts_with (RandomAccessIt1 begin1, RandomAccessIt1 end1, RandomAccessIt2 begin2, RandomAccessIt2 end2, BinaryPred pred={}) -> enable_if_t< is_random_access_iterator_v< RandomAccessIt1 > and is_random_access_iterator_v< RandomAccessIt2 >, bool >
 Checks if a given range starts with a particular subrange. More...
 
template<typename BidirIt1 , typename BidirIt2 , typename BinaryPred = std::equal_to<>>
constexpr auto kblib::ends_with (BidirIt1 begin1, BidirIt1 end1, BidirIt2 begin2, BidirIt2 end2, BinaryPred pred={}) -> enable_if_t<(is_bidirectional_iterator_v< BidirIt1 > and is_bidirectional_iterator_v< BidirIt2 >) and not(is_random_access_iterator_v< BidirIt1 > and is_random_access_iterator_v< BidirIt2 >), bool >
 Checks if a given range ends with a particular subrange. More...
 
template<typename RandomAccessIt1 , typename RandomAccessIt2 , typename BinaryPred = std::equal_to<>>
constexpr auto kblib::ends_with (RandomAccessIt1 begin1, RandomAccessIt1 end1, RandomAccessIt2 begin2, RandomAccessIt2 end2, BinaryPred pred={}) -> enable_if_t< is_random_access_iterator_v< RandomAccessIt1 > and is_random_access_iterator_v< RandomAccessIt2 >, bool >
 Checks if a given range ends with a particular subrange. More...
 
template<typename InputIt , typename EndIt , typename T , typename UnaryTransform >
constexpr auto kblib::first_result (InputIt begin, EndIt end, T def, UnaryTransform op) -> enable_if_t< is_input_iterator< InputIt >::value, std::decay_t< decltype(op(*begin))> >
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename T , typename BinaryTransform >
constexpr auto kblib::first_result (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, T def, BinaryTransform op) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value, std::decay_t< decltype(op(*begin1, *begin2))> >
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename EndIt2 , typename T , typename BinaryTransform >
constexpr auto kblib::first_result (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, EndIt2 end2, T def, BinaryTransform op) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value, std::decay_t< decltype(op(*begin1, *begin2))> >
 
template<typename InputIt , typename EndIt , typename T , typename UnaryTransform , typename UnaryPredicate >
constexpr auto kblib::first_result_if (InputIt begin, EndIt end, T def, UnaryTransform op, UnaryPredicate ch) -> enable_if_t< is_input_iterator< InputIt >::value, decltype(op(*begin))>
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename T , typename BinaryTransform , typename BinaryPredicate >
constexpr auto kblib::first_result_if (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, T def, BinaryTransform op, BinaryPredicate ch) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value, decltype(op(*begin1, *begin2))>
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename EndIt2 , typename T , typename BinaryTransform , typename BinaryPredicate >
constexpr auto kblib::first_result_if (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, EndIt2 end2, T def, BinaryTransform op, BinaryPredicate ch) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value, decltype(op(*begin1, *begin2))>
 
template<typename InputIt , typename EndIt , typename T , typename UnaryTransform >
constexpr auto kblib::first_result_opt (InputIt begin, EndIt end, T def, UnaryTransform op) -> enable_if_t< is_input_iterator< InputIt >::value, std::decay_t< decltype(op(*begin))> >
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename T , typename BinaryTransform >
constexpr auto kblib::first_result_opt (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, T def, BinaryTransform op) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value, std::decay_t< decltype(op(*begin1, *begin2))> >
 
template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename EndIt2 , typename T , typename BinaryTransform >
constexpr auto kblib::first_result_opt (InputIt1 begin1, EndIt1 end1, InputIt2 begin2, EndIt2 end2, T def, BinaryTransform op) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value, std::decay_t< decltype(op(*begin1, *begin2))> >
 
template<typename InputIt , typename UnaryPredicate >
constexpr auto kblib::all_of (InputIt begin, InputIt end, UnaryPredicate pred) -> enable_if_t< is_input_iterator< InputIt >::value, bool >
 Determine if pred is true for every element of the range. More...
 
template<typename Range , typename UnaryPredicate >
constexpr auto kblib::all_of (Range &&rng, UnaryPredicate pred) -> enable_if_t< is_iterable< Range >::value, bool >
 Determine if pred is true for every element of the range. More...
 
template<typename InputIt , typename UnaryPredicate >
constexpr auto kblib::none_of (InputIt begin, InputIt end, UnaryPredicate pred) -> enable_if_t< is_input_iterator< InputIt >::value, bool >
 Determine if pred is false for every element of the range. More...
 
template<typename Range , typename UnaryPredicate >
constexpr auto kblib::none_of (Range &&rng, UnaryPredicate pred) -> enable_if_t< is_iterable< Range >::value, bool >
 Determine if pred is true for every element of the range. More...
 
template<typename InputIt , typename UnaryPredicate >
constexpr auto kblib::any_of (InputIt begin, InputIt end, UnaryPredicate pred) -> enable_if_t< is_input_iterator< InputIt >::value, bool >
 Determine if pred is true for at least one element of the range. More...
 
template<typename Range , typename UnaryPredicate >
constexpr auto kblib::any_of (Range &&rng, UnaryPredicate pred) -> enable_if_t< is_iterable< Range >::value, bool >
 Determine if pred is true for every element of the range. More...
 
template<typename InputIt , typename Value >
constexpr auto kblib::contains (InputIt begin, InputIt end, const Value &val) noexcept(noexcept(*begin==val)) -> enable_if_t< is_input_iterator< InputIt >::value, bool >
 Determine if a range contains a value. More...
 
template<typename Set , typename Value >
constexpr auto kblib::contains (const Set &set, const Value &val) noexcept(noexcept(*std::declval< iterator_type_for_t< const Set > & >()==val)) -> enable_if_t< is_iterable< Set >::value, bool >
 Determine if a range contains a value. More...
 
template<typename InputIt1 , typename InputIt2 >
constexpr auto kblib::contains_any (InputIt1 begin, InputIt1 end, InputIt2 n_begin, InputIt2 n_end) -> enable_if_t< is_input_iterator< InputIt1 >::value and is_input_iterator< InputIt2 >::value, bool >
 
template<typename InputIt , typename Range2 >
constexpr auto kblib::contains_any (InputIt begin, InputIt end, Range2 &&needle) -> enable_if_t< is_input_iterator< InputIt >::value and is_iterable< Range2 >::value, bool >
 
template<typename Range1 , typename Range2 >
constexpr auto kblib::contains_any (Range1 &&haystack, Range2 &&needle) -> enable_if_t< is_iterable< Range1 >::value and is_iterable< Range2 >::value, bool >
 
template<typename ForwardIt , typename EndIt , typename Compare = std::less<>>
constexpr auto kblib::max_element (ForwardIt first, EndIt last, Compare comp={}) -> ForwardIt
 
template<typename SequenceContainer , typename Comp = std::less<>, typename It , enable_if_t< is_linear_container_v< SequenceContainer >, int > = 0>
constexpr auto kblib::get_max_n_old (It first, It last, std::size_t count, Comp cmp={}) -> SequenceContainer
 Returns a container of the greatest count elements according to cmp of the range [first, last), in arbitrary order. This overload works for linear containers. More...
 
template<typename SequenceContainer , typename Comp = std::less<>, typename It , enable_if_t< is_linear_container_v< SequenceContainer >, int > = 0>
constexpr auto kblib::get_max_n (It first, It last, std::size_t count, Comp cmp={}) -> SequenceContainer
 Returns a container of the greatest count elements according to cmp of the range [first, last), in descending order. This overload works for linear containers. More...
 
template<typename Comp = std::less<>, typename InputIt , typename OutputIt , typename Elem = typename std::iterator_traits<InputIt>::value_type>
constexpr auto kblib::get_max_n (InputIt first, InputIt last, OutputIt d_begin, std::size_t count, Comp cmp={}) -> return_assert_t< is_output_iterator_for< OutputIt, Elem >::value, OutputIt >
 Copies the count greatest elements according to cmp of the range [first, last) to the range beginning at d_begin. More...
 
template<typename ForwardIt , typename EndIt , typename ForwardIt2 , typename BinaryFunction >
constexpr auto kblib::for_each (ForwardIt first, EndIt last, ForwardIt2 second, BinaryFunction f) -> BinaryFunction
 Applies a binary operation to each pair of corresponding elements in two input ranges. It also allows for a sentinel end iterator. More...
 
template<typename ForwardIt , typename ForwardIt2 , typename Size , typename BinaryFunction >
constexpr auto kblib::for_each_n (ForwardIt first, Size n, ForwardIt2 second, BinaryFunction f) -> std::pair< ForwardIt, ForwardIt2 >
 Applies a binary operation to each pair of corresponding elements in two input ranges. More...
 
template<typename InputIt , typename EndIt , typename OutputIt >
constexpr auto kblib::copy (InputIt first, EndIt last, OutputIt out) -> OutputIt
 Copies all elements of [first, last) to out. It also allows for a sentinel end iterator. More...
 
template<typename InputIt , typename EndIt , typename OutputIt , typename UnaryPredicate >
constexpr auto kblib::copy_if (InputIt first, EndIt last, OutputIt out, UnaryPredicate pred) -> OutputIt
 Copies those elements of [first, last) which satisfy pred to out. It also allows for a sentinel end iterator. More...
 
template<typename InputIt , typename Size , typename OutputIt >
constexpr auto kblib::copy_n (InputIt first, Size count, OutputIt out) -> OutputIt
 Copies all elements of [first, std::advance(first, n)) to out. More...
 
template<typename InputIt , typename Size , typename OutputIt , typename UnaryPredicate >
constexpr auto kblib::copy_n_if (InputIt first, Size count, OutputIt out, UnaryPredicate pred) -> OutputIt
 Copies those elements of [first, std::advance(first, n)) which satisfy pred to out. More...
 
template<typename InputIt , typename EndIt , typename OutputIt , typename UnaryPredicate , typename T >
constexpr auto kblib::replace_copy_if (InputIt first, EndIt last, OutputIt out, UnaryPredicate pred, const T &new_value) -> OutputIt
 Copies an input range, but every element for which pred is true is replaced by new_value. It also allows for a sentinel end iterator. More...
 
template<typename InputIt , typename Size , typename OutputIt , typename UnaryPredicate , typename T >
constexpr auto kblib::replace_copy_n_if (InputIt first, Size count, OutputIt out, UnaryPredicate pred, const T &new_value) -> OutputIt
 Copies an input range, but every element for which pred is true is replaced by new_value. More...
 
template<typename ForwardIt1 , typename ForwardIt2 , typename ForwardIt3 , typename OutputIt , typename BinaryPredicate = std::equal_to<>>
constexpr auto kblib::search_replace_copy (ForwardIt1 h_begin, ForwardIt1 h_end, ForwardIt2 n_begin, ForwardIt2 n_end, ForwardIt3 r_begin, ForwardIt3 r_end, OutputIt d_begin, BinaryPredicate Compare={}) -> OutputIt
 
template<typename Haystack , typename Needle , typename Replacement , typename OutputIt , typename BinaryPredicate = std::equal_to<>>
constexpr auto kblib::search_replace_copy (Haystack &&haystack, Needle &&needle, Replacement &&replacement, OutputIt d_begin, BinaryPredicate compare={})
 
template<class ForwardIt >
constexpr auto kblib::rotate (ForwardIt first, ForwardIt n_first, ForwardIt last) noexcept(noexcept(swap(*first, *first))) -> ForwardIt
 Rotates the input range. This is just a constexpr-in-C++14 version of std::rotate. More...
 
template<typename OutputIt , typename EndIt , typename Generator >
constexpr auto kblib::generate (OutputIt first, EndIt last, Generator g) noexcept(noexcept(*++first=g())) -> OutputIt
 Like std::generate except that it returns the output iterator at the end. It also allows for a sentinel end iterator. More...
 
template<typename OutputIt , typename Size , typename Generator >
constexpr auto kblib::generate_n (OutputIt first, Size count, Generator g) noexcept(noexcept(*first++=g())) -> OutputIt
 Like std::generate_n except that it is constexpr. More...
 
template<typename ForwardIt , typename T >
constexpr auto kblib::iota (ForwardIt first, ForwardIt last, T value) noexcept(noexcept(*first++=value) and noexcept(++value)) -> void
 
template<typename ForwardIt , typename T , typename UnaryOperation >
constexpr auto kblib::iota (ForwardIt first, ForwardIt last, T value, UnaryOperation unary_op) noexcept(noexcept(*first++=value) and noexcept(kblib::invoke(unary_op, std::move(value)))) -> void
 
template<typename InputIt , typename EndIt , typename... Params>
constexpr auto kblib::call_each (InputIt first, EndIt last, Params &&... params) noexcept(noexcept(kblib::invoke(*first++, std::forward< Params >(params)...))) -> InputIt
 
template<typename InputIt , typename EndIt , typename OutputIt , typename UnaryOperation >
constexpr auto kblib::transform (InputIt first, EndIt last, OutputIt d_first, UnaryOperation unary_op) -> OutputIt
 transform applies the given function to a range and stores the result in another range, beginning at d_first. The unary operation unary_op is applied to the range defined by [first1, last1). It also allows for a sentinel end iterator. More...
 
template<typename InputIt , typename EndIt , typename InputIt2 , typename OutputIt , typename BinaryOperation >
constexpr auto kblib::transform (InputIt first, EndIt last, InputIt first2, OutputIt d_first, BinaryOperation binary_op) -> OutputIt
 transform applies the given function to a range and stores the result in another range, beginning at d_first. The unary operation unary_op is applied to the range defined by [first1, last1). It also allows for a sentinel end iterator. More...
 
template<typename InputIt , typename EndIt , typename OutputIt , typename UnaryPredicate , typename UnaryOperation >
constexpr auto kblib::transform_if (InputIt first, EndIt last, OutputIt d_first, UnaryPredicate pred, UnaryOperation unary_op) -> OutputIt
 transform applies the given function to a range and stores the result in another range, beginning at d_first. The unary operation unary_op is applied to the range defined by [first1, last1). It also allows for a sentinel end iterator. More...
 
template<class ForwardIt >
constexpr auto kblib::detail_algorithm::shift_backward (ForwardIt first, ForwardIt n_first, ForwardIt last) noexcept(noexcept(*first=std::move(*first))) -> void
 Implementation function for insertion_sort_copy. Like std::move(begin, end, d_begin) but using the interface of rotate and supporting backward overlapping, but not forward overlapping. More...
 

Detailed Description

Provides general-purpose algorithms, similar to the <algorithms> header.

Author
killerbee
Date
2019-2021

Definition in file algorithm.h.