kblib  0.2.3
General utilities library for modern C++
kblib Namespace Reference

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

Namespaces

 asserts
 
 best_lcgs
 
 common_lcgs
 
 detail
 The namespace used for implementation details within kblib.
 
 detail_algorithm
 
 detail_bits
 
 detail_convert
 
 detail_cry
 
 detail_direct_map
 
 detail_enumerate
 
 detail_hash
 
 detail_io
 
 detail_iterators
 
 detail_memory
 
 detail_poly
 Implementation details for poly_obj.
 
 detail_sort
 
 detail_units
 
 fakestd
 A namespace which holds all the C++14 implementations of C++17 standard library features. In C++17, it is simply defined as an alias to std.
 
 fnv
 
 icu_str_ops
 
 lcgs
 
 literals
 
 multi_impl
 
 nums
 

Classes

struct  equivalent
 A function object implementing the equivalence relationship over a comparison predicate. More...
 
struct  equivalent< void, Obj >
 
struct  equivalent< Compare, void >
 
struct  equivalent< void, void >
 
struct  is_optional
 
struct  is_optional< std::optional< U > >
 
class  compact_bit_trie
 
struct  bitfield
 Implements a bitfield abstraction. May be used in a union with other bitfields. More...
 
struct  punner
 
class  union_pun
 
class  union_pun< Type[N], Storage >
 
struct  exists_t
 
struct  construct_with_size
 
struct  construct_with_capacity
 
class  build_iterator
 
struct  build_end_t
 
class  build_iterator< Container, true >
 
class  stack
 
struct  constant
 
struct  lexical_caster
 
struct  lexical_caster< Same, Same >
 
struct  lexical_caster< std::string, std::string >
 
struct  lexical_caster< std::string, From >
 
struct  lexical_caster< To, std::string >
 
class  delayed_construct
 
struct  FNV_hash< delayed_construct< T >, void >
 
class  direct_map
 
class  direct_map< Key, T, void >
 
struct  enumerate_iterator
 
struct  enumerate_t
 
struct  enumerate_t< Range, void >
 
struct  meta_type
 
struct  meta_type< T >
 
struct  void_if
 
struct  void_if< true >
 
struct  metafunction_success
 
struct  metafunction_success< T, void_t< typename T::type > >
 
struct  is_callable
 
struct  return_assert
 Essentially just like std::enable_if, but with a different name that makes it clearer what it does in the context of return type SFINAE. More...
 
struct  return_assert< true, T >
 
struct  has_member_swap
 
struct  is_tuple_like
 
struct  is_tuple_like< T, void_t< typename std::tuple_element< 0, T >::type > >
 
struct  safe_signed
 
struct  safe_signed< N, std::enable_if_t< std::is_integral< N >::value, void > >
 
struct  copy_const
 
struct  copy_const< C, T, true >
 
struct  copy_const< C, T &, true >
 
struct  copy_const< C, T &&, true >
 
struct  value_detected
 
struct  value_detected< T, void_t< typename T::value_type > >
 
struct  key_detected
 
struct  key_detected< T, void_t< typename T::key_type > >
 
struct  mapped_detected
 
struct  mapped_detected< T, void_t< typename T::mapped_type > >
 
struct  hash_detected
 
struct  hash_detected< T, void_t< typename T::hasher > >
 
struct  value_type_linear
 
struct  value_type_linear< Container, false, typename Container::value_type >
 
struct  is_linear_container
 
struct  key_type_setlike
 
struct  key_type_setlike< Container, true, false >
 
struct  in_place_agg_t
 
class  heap_value
 
class  heap_value2
 
class  heap_value2< T[], D >
 
struct  padding_bits
 Get the number of padding bits in an integral type. More...
 
struct  FNV_hash
 The primary template has to exist, but not be constructible, in order to be compatible with std::hash. More...
 
struct  is_hashable
 
struct  is_hashable< Key, void_if_t< std::is_constructible< FNV_hash< Key > >::value > >
 
struct  FNV_hash< bool, HashInt, void >
 Hasher for bool. More...
 
struct  FNV_hash< char, HashInt, void >
 Hasher for char. More...
 
struct  FNV_hash< signed char, HashInt, void >
 Hasher for signed char. More...
 
struct  FNV_hash< unsigned char, HashInt, void >
 Hasher for unsigned char. More...
 
struct  FNV_hash< T, HashInt, void_if_t< std::is_empty< T >::value > >
 An empty type is treated as if it were a single null byte. More...
 
struct  is_trivially_hashable
 
struct  FNV_hash< T, HashInt, void_if_t< std::is_integral< T >::value and is_trivially_hashable_v< T > > >
 Hasher for any trivially hashable type not explicitly mentioned above. More...
 
struct  FNV_hash< T, HashInt, void_if_t< std::is_pointer< T >::value > >
 Hasher for any pointer type. More...
 
struct  FNV_hash< T, HashInt, void_if_t<(std::is_base_of< std::forward_iterator_tag, typename std::iterator_traits< T >::iterator_category >::value and not std::is_pointer< T >::value and not is_trivially_hashable_v< T > and std::is_pointer< typename fakestd::invoke_result< decltype(&T::operator->), T >::type >::value)> >
 Hasher for any forward iterator type. More...
 
struct  FNV_hash< Container, HashInt, void_if_t<(is_contiguous_v< Container > and is_trivially_hashable_v< typename Container::value_type >)> >
 Container hasher, for contiguously-stored trivial elements. More...
 
struct  FNV_hash< T, HashInt, void_if_t< not is_contiguous< T >::value and not std::is_integral< T >::value and not std::is_pointer< T >::value and is_trivially_hashable_v< T > > >
 Hasher for any non-integral trivially copyable type that has no padding. More...
 
struct  FNV_hash< Container, HashInt, void_if_t< value_detected< Container >::value and is_hashable_v< value_detected_t< Container > > and not hash_detected< Container >::value and is_iterable< Container >::value and not(is_contiguous< Container >::value and is_trivially_hashable_v< typename Container::value_type >) and not is_iterator_v< Container > > >
 Container hasher, for non-trivial elements (or non-contiguous storage) More...
 
struct  FNV_hash< std::optional< T >, HashInt, void >
 
struct  FNV_hash< void, HashInt, void >
 Transparent hasher for any hashable type. More...
 
class  intrusive_hash_map
 
class  intrusive_dual_map
 
struct  get_manip
 A helper class for wrapping stream manipulators. More...
 
struct  unicode_widen
 
struct  unicode_widen< char16_t, char32_t >
 
class  basic_teestream
 
struct  file_deleter
 
struct  to_pointer_impl
 
struct  to_pointer_impl< T * >
 
struct  is_output_iterator_for
 Determine if T is a valid output iterator to which values of type E may be written. More...
 
struct  is_output_iterator_for< T, E, void_t< decltype(*std::declval< T & >()++=std::declval< const E & >())> >
 
class  counting_back_insert_iterator
 Like a std::back_insert_iterator, but it keeps track of how many insertions it has made, allowing an end iterator to be created. More...
 
class  range_t
 A range generator, similar to Python 3's range(). More...
 
struct  adjuster
 
struct  incrementer
 A struct which increments anything it is added to. Suitable for use as a Delta type for range_t. More...
 
struct  decrementer
 A struct which decrements anything it is added to. Suitable for use as a Delta type for range_t. More...
 
class  irange_t
 
class  enumerator_iterator
 
class  enumeration
 
class  enumerator_t
 
class  enumerator_t< Range, void >
 
struct  indirect_range
 Allow range-for iteration of an iterator pair. More...
 
class  multi_range
 
class  multi_range< Iter1, EndIter, 0 >
 
struct  containing_ptr
 A smart pointer to an object contained inside the smart pointer object. More...
 
class  transform_iterator
 An InputIterator that applies a transformation to the elements of the range. More...
 
struct  zip_iterator
 
struct  zip_iterator< It1, It1, It2 >
 
class  adjacent_iterator
 TODO(killerbee): Implement adjacent_iterator. More...
 
class  back_insert_iterator_F
 An OutputIterator that transforms the values assigned to it before inserting them into the back of a container. More...
 
class  consume_iterator
 An OutputIterator that simply calls a provided functor for each value assigned to it. More...
 
struct  implies
 A metafunction for logical implication. That is, if A, then B. If not A, B is unimportant. More...
 
struct  implies< true, false >
 Logical implication is only not satisfied by true -> false. More...
 
struct  null_construct
 
struct  null_construct< T, true >
 
class  live_ptr
 
class  live_wrapper
 
class  live_wrapper< const T >
 
class  live_ptr< const mT >
 
class  cond_ptr
 
class  cond_ptr< T[], Deleter >
 
class  multi_span
 
struct  default_copy
 Implements type erasure for copy construction. More...
 
struct  default_copy< Obj, false >
 
struct  clone_copy
 Implements copy construction using a virtual clone method. This type is provided mostly as an example. More...
 
struct  default_move
 Implements type erasure for move construction. More...
 
struct  default_move< Obj, false, nothrow, false >
 
struct  default_move< Obj, false, nothrow, true >
 
struct  default_destroy
 Uses the class's virtual destructor. More...
 
struct  poly_obj_traits
 poly_obj_traits is a traits class template which abstracts the allowed operations on a polymorphic type hierarchy. Any operation allowed by the traits must be usable for the entire hierarchy, not just the base class. More...
 
class  poly_obj
 Inline polymorphic object. Generally mimics the interfaces of std::optional and std::variant. More...
 
class  trivial_seed_seq
 
struct  state_size
 
struct  state_size< std::mersenne_twister_engine< UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f > >
 
struct  state_size< std::linear_congruential_engine< UIntType, a, c, m > >
 
struct  state_size< std::subtract_with_carry_engine< UIntType, w, s, r > >
 
struct  state_size< std::discard_block_engine< Engine, P, R > >
 
struct  state_size< std::independent_bits_engine< Engine, W, UIntType > >
 
struct  state_size< std::shuffle_order_engine< Engine, K > >
 
class  transform_engine
 
struct  state_size< transform_engine< Engine, Transform > >
 
struct  shift_mask
 
struct  RAII_wrapper
 
struct  first_bigger_than
 
struct  first_bigger_than< size, T >
 
struct  identity
 The identity function, as a function object. More...
 
struct  is_radix_sortable
 
struct  is_radix_sortable< T, void_if_t< std::is_integral< T >::value > >
 
struct  is_radix_sortable< T, void_if_t< std::is_enum< T >::value > >
 
struct  is_radix_sortable< std::bitset< B >, void >
 
struct  is_radix_sortable< T, void_if_t< is_linear_container_v< T > and std::is_integral< typename T::value_type >::value > >
 
struct  is_trivial_transformation
 
struct  is_trivial_transformation< identity >
 
struct  trivial_pair
 std::pair isn't constexpr enough, so I'm stuck with this. All I use it for is removing a temporary variable from calc_fib_size(). More...
 
struct  trivial_array
 std::array isn't constexpr enough in C++14, so a dedicated array class is needed for constexpr functions. More...
 
struct  contains_type
 Determines if T is a type in Tuple, which must be a std::tuple. More...
 
struct  contains_type< std::tuple< T, Ts... >, U >
 
struct  contains_type< std::tuple< T, Ts... >, T >
 
struct  contains_type< std::tuple<>, T >
 
struct  contains_types
 Determines if Lhs contains all of the types in Rhs, where both are std::tuples. More...
 
struct  contains_types< Tuple, std::tuple< T, Ts... > >
 
struct  contains_types< Tuple, std::tuple<> >
 
struct  list_as_tuple
 
struct  list_as_tuple< Tuple< Ts... > >
 
struct  is_unbounded_array
 
struct  is_unbounded_array< T[]>
 
struct  is_bounded_array
 
struct  is_bounded_array< T[N]>
 
struct  ignore
 Ignores its first template argument entirely, and returns its second. More...
 
struct  is_resizable
 
struct  has_reserve
 True if and only if C contains an accessible reserve() member. More...
 
struct  is_contiguous
 
struct  class_of
 
struct  class_of< M T::* >
 
struct  member_of
 
struct  member_of< M T::* >
 
struct  return_type
 
struct  return_type< R(Args...)>
 
struct  return_type< R(Args...) const >
 
struct  return_type< R(Args...) volatile >
 
struct  return_type< R(Args...) const volatile >
 
struct  exists
 
struct  is_input_iterator
 
struct  is_input_iterator< T, void_if_t< std::is_base_of< std::input_iterator_tag, typename std::iterator_traits< T >::iterator_category >::value > >
 
struct  is_forward_iterator
 
struct  is_forward_iterator< T, void_if_t< std::is_base_of< std::forward_iterator_tag, typename std::iterator_traits< T >::iterator_category >::value > >
 
struct  is_bidirectional_iterator
 
struct  is_bidirectional_iterator< T, void_if_t< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< T >::iterator_category >::value > >
 
struct  is_random_access_iterator
 
struct  is_random_access_iterator< T, void_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< T >::iterator_category >::value > >
 
struct  iterator_type_for
 Type trait that determines the iterator type for a range. More...
 
struct  iterator_type_for< T[N], void >
 
struct  iterator_type_for< Range, void_t< decltype(begin(std::declval< Range & >()))> >
 
struct  is_iterable
 
struct  is_iterable< Range, void_if_t< is_input_iterator< decltype(begin(std::declval< Range & >()))>::value > >
 
struct  is_iterable< T[N], void >
 
struct  is_iterable< T(&)[N], void >
 
struct  is_iterator
 
struct  is_iterator< T, void_t< decltype(*std::declval< T & >(), void(),++std::declval< T & >())> >
 
struct  type_constant
 
struct  is_aliasing_type
 
struct  is_aliasing_type< char >
 
struct  is_aliasing_type< unsigned char >
 
struct  iterator_extractor
 
struct  indexer_extractor
 
struct  extractor_policy_for
 
struct  extractor_policy_for< Container, void_t< decltype(std::declval< Container >()[0])> >
 
class  trie
 
class  trie< KeyElem, T, Extractor, false >
 
class  trie< KeyElem[], T, Extractor, false >
 
struct  is_variant_like
 
struct  visitor
 Helper class for std::visiting a std::variant. More...
 
struct  max_t
 Shorthand for std::numeric_limits::max(). More...
 
struct  min_t
 Shorthand for std::numeric_limits::min() More...
 

Typedefs

template<bool B, typename T = void>
using enable_if_t = typename std::enable_if< B, T >::type
 
template<typename T >
using decay_t = typename std::decay< T >::type
 
template<typename T >
using remove_cvref_t = typename std::remove_reference< typename std::remove_cv< T >::type >::type
 
template<bool v>
using bool_constant = std::integral_constant< bool, v >
 
template<typename... Ts>
using meta_type_t = typename meta_type< Ts... >::type
 
template<bool b>
using void_if_t = typename void_if< b >::type
 
template<typename T >
using metafunction_value_t = std::integral_constant< decltype(T::value), T::value >
 
template<bool V, typename T >
using return_assert_t = typename return_assert< V, T >::type
 
template<typename N >
using safe_signed_t = typename safe_signed< N >::type
 
template<typename C , typename V >
using copy_const_t = typename copy_const< C, V >::type
 
template<typename T >
using value_detected_t = typename value_detected< T >::type
 
template<typename T >
using key_detected_t = typename key_detected< T >::type
 
template<typename T >
using mapped_detected_t = typename mapped_detected< T >::type
 
template<typename T >
using hash_detected_t = typename hash_detected< T >::type
 
template<typename Container >
using value_type_linear_t = typename value_type_linear< Container >::type
 
template<typename Container >
using key_type_setlike_t = typename key_type_setlike< Container >::type
 
template<typename Key >
using FNV32_hash = FNV_hash< Key, std::uint32_t >
 
template<typename Key , typename Value >
using hash_map = std::unordered_map< Key, Value, FNV_hash< Key > >
 
template<typename Key , typename Value >
using hash_multimap = std::unordered_multimap< Key, Value, FNV_hash< Key > >
 
template<typename T , typename HashInt >
using hash_set = std::unordered_set< T, FNV_hash< T > >
 
template<typename T , typename HashInt >
using hash_multiset = std::unordered_set< T, FNV_hash< T > >
 
template<typename Obj >
using move_only_traits = poly_obj_traits< Obj, construct_type::move >
 
template<typename Obj >
using no_move_traits = poly_obj_traits< Obj, construct_type::none >
 
template<typename UIntType , UIntType a, UIntType c, UIntType b>
using lcg_p2 = std::linear_congruential_engine< UIntType, a, c, ipow2(b)>
 
using rand48 = transform_engine< lcg_p2< std::uint_fast64_t, 25214903917u, 11u, 48u >, shift_mask< std::uint_fast32_t, 16u > >
 
using lcg32 = lcg_p2< std::uint_fast32_t, 0xa13fc965u, 1u, 32u >
 
using mcg32 = lcg_p2< std::uint_fast32_t, 0x93d765ddu, 0u, 32u >
 
using lcg48 = lcg_p2< std::uint_fast64_t, 0xb67a49a5466du, 1u, 48u >
 
using mcg48 = lcg_p2< std::uint_fast64_t, 0xbdcdbb079f8du, 0u, 48u >
 
using lcg64 = lcg_p2< std::uint_fast64_t, 0xaf251af3b0f025b5u, 1u, 64u >
 
using mcg64 = lcg_p2< std::uint_fast64_t, 0xf1357aea2e62a9c5u, 0u, 64u >
 
template<std::uintmax_t I>
using uint_smallest = typename first_bigger_than< 1+filg2(I)/CHAR_BIT, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, std::uintmax_t >::type
 
template<std::uintmax_t I>
using int_smallest = typename first_bigger_than< 1+(filg2(I)+1)/CHAR_BIT, signed char, signed short, signed int, signed long, signed long long, std::uintmax_t >::type
 
template<std::uintmax_t I>
using uint_smallest_t = typename uint_smallest< I >::type
 
template<std::uintmax_t I>
using int_smallest_t = typename int_smallest< I >::type
 
template<typename T >
using alias = T
 A simple identity alias for simplifying some compound type declarations, such as function pointers. More...
 
template<typename U , typename T >
using ignore_t = typename ignore< U, T >::type
 An alias for ignore<U, T>::type. More...
 
template<typename T >
using class_of_t = typename class_of< T >::type
 
template<typename T >
using member_of_t = typename member_of< T >::type
 
template<typename Range >
using iterator_type_for_t = typename iterator_type_for< Range >::type
 
template<typename T >
using remove_reference_t = typename std::remove_reference< T >::type
 Abbreviated name for std::remove_reference<T>::type for C++14. More...
 

Enumerations

enum class  construct_type : unsigned {
  none = 0 , copy_only = 1 , move = 2 , both = 3 ,
  throw_move = 4 , both_throw = 5
}
 
enum class  endian { unknown , little , big , weird }
 
enum class  extractor_policy { forward_iteration , random_access }
 

Functions

template<typename Callable >
constexpr auto 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 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 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 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 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 accumulate (InputIt first, InputIt last, T init) -> T
 A constexpr version of std::accumulate. More...
 
template<class InputIt , class T , class BinaryOperation >
constexpr auto accumulate (InputIt first, InputIt last, T init, BinaryOperation op) -> T
 A constexpr version of std::accumulate. More...
 
template<typename InputIt >
constexpr auto sum (InputIt first, InputIt last) -> std::decay_t< decltype(*first)>
 Sum a range. More...
 
template<typename InputIt , typename BinaryOperation >
constexpr auto sum (InputIt first, InputIt last, BinaryOperation op) -> std::decay_t< decltype(*first)>
 Fold a range over an operation. More...
 
template<typename Range >
constexpr auto sum (Range &&r) -> auto
 Sum a range. More...
 
template<typename InputIt , typename EndIt , typename OutputIt , typename T , typename BinaryAccumulation , typename UnaryTransform >
constexpr auto 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 ends with a particular subrange. More...
 
template<typename BidirIt1 , typename BidirIt2 , typename BinaryPred = std::equal_to<>>
constexpr auto 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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<class ForwardIt >
constexpr auto 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 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 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 iota (ForwardIt first, ForwardIt last, T value) noexcept(noexcept(*first++=value) and noexcept(++value)) -> void
 
template<typename ForwardIt , typename T , typename UnaryOperation >
constexpr auto 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 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 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 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 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...
 
constexpr auto memswap (unsigned char *A, unsigned char *B, std::size_t size) noexcept -> void
 Swaps memory ranges. More...
 
auto memswap (void *A, void *B, std::size_t size) noexcept -> void
 Swaps memory ranges. More...
 
template<std::size_t I, typename... Types>
auto get (punner< Types... > &p) noexcept -> decltype(auto)
 
template<std::size_t I, typename... Types>
auto get (const punner< Types... > &p) noexcept -> decltype(auto)
 
template<std::size_t I, typename... Types>
auto get (punner< Types... > &&p) noexcept -> decltype(auto)
 
template<std::size_t I, typename... Types>
auto get (const punner< Types... > &&p) noexcept -> decltype(auto)
 
template<typename Container , typename InputIt , typename UnaryFunction >
auto build (InputIt first, InputIt last, UnaryFunction f, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 Constructs a container by applying a UnaryFunction to every element of an input range. More...
 
template<typename Container , typename InputIt , typename InputIt2 , typename BinaryFunction >
auto build (InputIt first, InputIt last, InputIt2 first2, BinaryFunction f, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 Constructs a container by applying a BinaryFunction to every pair of elements in the input ranges. More...
 
template<typename Array , typename InputIt , typename UnaryFunction , enable_if_t< not is_resizable_v< Array >, int > = 0>
auto build (InputIt first, InputIt last, UnaryFunction f) -> Array
 Constructs an array-like container by applying a UnaryFunction to every element of an input range. More...
 
template<typename Array , typename InputIt , typename InputIt2 , typename BinaryFunction , enable_if_t< not is_resizable_v< Array >, int > = 0>
auto build (InputIt first, InputIt last, InputIt2 first2, BinaryFunction f) -> Array
 Constructs an array-like container by applying a BinaryFunction to every pair of elements in the input ranges. More...
 
template<typename Container , typename Functor >
auto build (Functor f, size_t size, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 Constructs a container with elements initialized by repeatedly calling a generating function. More...
 
template<typename Array , typename Functor , enable_if_t< not is_resizable_v< Array >, int > = 0>
auto build (Functor f, size_t size=std::tuple_size< Array >::value) -> Array
 Constructs an array-like container with elements initialized by repeatedly calling a generating function. More...
 
template<typename Container , typename InputIt , typename UnaryFunction >
auto build_dy (InputIt first, InputIt last, UnaryFunction f) -> Container
 Constructs a container by applying a UnaryFunction to every element of an input range. Exactly like build, but for resizable non-AllocatorAware Containers (which are hard to detect automatically). More...
 
template<typename Container , typename InputIt , typename InputIt2 , typename BinaryFunction >
auto build_dy (InputIt first, InputIt last, InputIt2 first2, BinaryFunction f) -> Container
 Constructs a container by applying a BinaryFunction to every pair of elements in the input ranges. Exactly like build, but for resizable non-AllocatorAware Containers (which are hard to detect automatically). More...
 
template<typename Container , typename Functor >
auto build_dy (Functor f, size_t size) -> Container
 Constructs a container with elements initialized by repeatedly calling a generating function. Exactly like build, but for resizable non-AllocatorAware Containers (which are hard to detect automatically). More...
 
template<typename Container , typename Range , typename UnaryFunction , enable_if_t< is_resizable_v< Container >, int > = 0>
auto build_dy (Range &&r, UnaryFunction f) -> Container
 
template<typename Container , typename... Args>
constexpr auto buildiota (Args &&... args) -> auto
 Builds a container of increasing values. More...
 
template<typename Container , typename InputIt >
auto build_copy (InputIt first, InputIt last, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 
template<typename Container , typename Range , enable_if_t< is_resizable_v< Container >, int > = 0>
auto build_copy (Range &&r) -> Container
 
template<typename Container , typename Range >
auto build_copy (Range &&r, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 
template<typename Container , typename InputIt , enable_if_t< not is_resizable_v< Container >, int > = 0>
constexpr auto build_copy (InputIt first, InputIt last) -> Container
 
template<typename Container , typename Range , enable_if_t< not is_resizable_v< Container >, int > = 0>
constexpr auto build_copy (Range &&r) -> Container
 
template<typename Container , typename InputIt , enable_if_t< not is_resizable_v< Container >, int > = 0>
auto build_copy (InputIt first, InputIt last, std::size_t size) -> Container
 
template<typename Container , typename Range , enable_if_t< not is_resizable_v< Container >, int > = 0>
auto build_copy (Range &&r, std::size_t size) -> Container
 
template<typename Container , typename InputIt , typename Predicate >
auto build_copy_if (InputIt first, InputIt last, Predicate f, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 
template<typename Container , typename InputIt , typename Size >
auto build_copy_n (InputIt first, Size count, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 
template<typename Container , typename InputIt , typename Size , typename Predicate >
auto build_copy_n_if (InputIt first, Size count, Predicate f, typename Container::allocator_type allocator=typename Container::allocator_type{}) -> Container
 
template<typename C >
constexpr auto pop (C &s) -> typename C::value_type
 
template<class C , typename K , typename V >
constexpr auto get_or (const C &m, const K &key, const V &defval) -> typename C::mapped_type
 
template<typename Map , typename Key >
constexpr auto try_get (Map &map, Key &&key) -> copy_const_t< Map, typename Map::mapped_type > *
 
template<typename M , typename K >
constexpr auto get_check (M &&m, const K &key) noexcept(noexcept(m.find(key) !=m.end())) -> exists_t< decltype(m.find(key))>
 
template<typename V >
auto force_shrink_to_fit (V &vec) -> void
 std::vector::shrink_to_fit is non-binding, which means that there is no guaranteed way to shrink a vector via its API. This function is a roundabout way of doing that without relying on the sanity of the implementation (except that it assumes that a vector won't significantly over-allocate on sized construction). More...
 
template<typename Container , typename Range >
constexpr auto construct_from_range (Range &&r) -> Container
 Allows for constructing a container of a specified type from a range object. Copy elision means that this does not result in any extra copies. More...
 
template<int base, typename Int >
auto to_string (Int num) -> std::string
 
template<typename Int >
auto to_string (Int num, int base) -> std::string
 
template<typename Result >
constexpr auto parse_integer (const char *begin, const char *end, int base=0) -> Result
 
template<typename Result , std::size_t N>
constexpr auto parse_integer (const char(&in)[N], int base=0) -> Result
 
template<typename Result >
constexpr auto parse_integer (const std::string &in, int base=0) -> Result
 
template<char... Cs>
constexpr auto operator""_c ()
 
template<char... Cs>
constexpr auto operator""_cu ()
 
template<typename E , typename = typename std::enable_if<std::is_enum<E>::value>::type>
constexpr auto etoi (E e) -> auto
 
template<int maxBufLen = 4096, typename clock , typename duration >
auto time_to_str (std::chrono::time_point< clock, duration > &tp, const std::string &fmt="%F %T") -> std::string
 
template<typename Rep , typename Ratio , enable_if_t< detail_units::is_si_ratio< typename Ratio::type >::value > * = 0>
auto duration_to_str (std::chrono::duration< Rep, Ratio > &d) -> std::string
 
template<typename Rep >
auto duration_to_str (std::chrono::duration< Rep, std::ratio< 60 >> d) -> std::string
 
template<typename Rep >
auto duration_to_str (std::chrono::duration< Rep, std::ratio< 3600 >> d) -> std::string
 
template<typename string >
auto url_encode (const string &value) -> std::string
 
template<typename string >
auto html_encode (const string &data) -> std::string
 
auto escapify (char c) -> std::string
 
template<typename string >
auto escapify (const string &value) -> std::string
 
template<typename string >
auto calculate_translated_index (string &&value, const char *p) -> std::ptrdiff_t
 
auto calculate_translated_index (const char *value, const char *p) -> std::ptrdiff_t
 
template<typename string >
auto quoted (string &&in) -> std::string
 
template<typename T >
auto fromStr (const std::string &val, const char *type=typeid(T).name()) -> T
 
template<>
auto fromStr (const std::string &val, const char *) -> std::string
 
template<typename T >
auto fromStr (std::string &&val, const char *type=typeid(T).name()) -> T
 
template<>
auto fromStr (std::string &&val, const char *) -> std::string
 
template<typename T >
auto toStr (T val) -> std::string
 
auto toStr (std::string val) -> std::string
 
template<typename To , typename From >
auto lexical_cast (const From &val, const char *type=typeid(To).name()) -> To
 
template<typename Range >
auto cry_enumerate (Range &&range) -> auto
 
template<typename Range >
constexpr auto enumerate (Range &&r) -> enumerate_t< Range && >
 Allow access to indexes while using range-based for loops. Safe to use with rvalues. More...
 
template<typename It , typename EIt >
constexpr auto enumerate (It begin, EIt end) -> enumerate_t< It, EIt >
 Allow access to indexes while using range-based for loops. More...
 
template<typename F , typename... Args>
constexpr auto invoke (F &&f, Args &&... args) noexcept(noexcept(detail::do_invoke(std::forward< F >(f), std::forward< Args >(args)...))) -> decltype(auto)
 
template<typename F , typename Arg >
constexpr auto apply (F &&f, Arg &&arg) noexcept(noexcept(detail::apply_impl< F, Arg >::do_apply(std::forward< F >(f), std::forward< Arg >(arg), std::index_sequence< std::tuple_size< Arg >::value >{}))) -> decltype(auto)
 
template<typename T >
auto to_unique (gsl::owner< T * > p) -> std::unique_ptr< T >
 
template<typename T , typename D >
auto to_unique (gsl::owner< T * > p, D &&d) -> std::unique_ptr< T, D >
 
template<typename I >
constexpr auto to_unsigned (I x) -> std::make_unsigned_t< I >
 Cast integral argument to corresponding unsigned type. More...
 
template<typename I >
constexpr auto to_signed (I x) -> std::make_signed_t< I >
 Cast integral argument to corresponding signed type. More...
 
template<typename A , typename F >
constexpr auto signed_cast (F x) -> enable_if_t< std::is_integral< A >::value and std::is_integral< F >::value and std::is_signed< A >::value, std::make_signed_t< F >>
 Cast argument to equivalently-sized type with the same signednessas the template parameter. More...
 
template<typename T , typename U = T>
constexpr auto exchange (T &obj, U &&new_value) -> T
 
template<typename N >
constexpr auto signed_promote (N x) noexcept -> safe_signed_t< N >
 
template<class InputIt1 , class InputIt2 >
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename BinaryPredicate , typename kblib::enable_if_t< not std::is_same< InputIt2, BinaryPredicate >::value, int > = 0>
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p) -> bool
 
template<class RandomIt1 , class RandomIt2 , typename kblib::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt1 >::iterator_category >::value and std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt2 >::iterator_category >::value, int > = 0>
constexpr auto equal (RandomIt1 first1, RandomIt1 last1, RandomIt2 first2, RandomIt2 last2) -> bool
 
template<class RandomIt1 , class RandomIt2 , typename BinaryPredicate , typename kblib::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt1 >::iterator_category >::value and std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt2 >::iterator_category >::value, int > = 0>
constexpr auto equal (RandomIt1 first1, RandomIt1 last1, RandomIt2 first2, RandomIt2 last2, BinaryPredicate p) -> bool
 
template<class InputIt1 , class InputIt2 , typename kblib::enable_if_t< not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt1 >::iterator_category >::value or not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt2 >::iterator_category >::value, int > = 0>
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool
 
template<typename InputIt1 , typename InputIt2 , typename BinaryPredicate , typename kblib::enable_if_t< not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt1 >::iterator_category >::value or not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt2 >::iterator_category >::value, int > = 0>
constexpr auto equal (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate p) -> bool
 
template<typename C >
constexpr auto size (const C &c) -> decltype(c.size())
 
template<typename T , std::size_t N>
constexpr auto size (const T(&)[N]) noexcept -> std::size_t
 
template<class InputIt1 , class InputIt2 >
constexpr auto lexicographical_compare (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -> bool
 
template<typename Number >
constexpr auto count_digits (Number val) -> enable_if_t< std::is_floating_point< Number >::value, int >
 Calculates the number of decimal digits needed to represent a number, plus one for negative numbers. More...
 
template<typename Number >
constexpr auto count_digits (Number val, int base) -> int
 Calculates the number of digits needed to represent a number in a given base, plus one for negative numbers. More...
 
template<typename ForwardIt >
auto max_count_digits (ForwardIt first, ForwardIt last) -> int
 Returns the necessary number of digits to represent the largest value in an input range. More...
 
template<typename ForwardIt >
auto max_count_digits (ForwardIt first, ForwardIt last, int base) -> int
 Returns the necessary number of digits to represent the largest value in an input range. More...
 
template<typename Integral , typename CharT >
constexpr auto to_bytes_le (Integral ival, CharT(&dest)[sizeof(Integral)]) noexcept -> void
 
template<typename Integral , typename CharT >
constexpr auto to_bytes_be (Integral ival, CharT(&dest)[sizeof(Integral)]) noexcept -> void
 
template<typename Integral , typename CharT >
constexpr auto to_bytes (Integral val, CharT(&dest)[sizeof(Integral)]) noexcept -> void
 
template<typename HashInt , typename Span >
constexpr auto FNVa (Span &&s, HashInt hval=fnv::fnv_offset< HashInt >::value) noexcept -> HashInt
 A templatized generic FNVa hash function. More...
 
template<typename HashInt , typename CharT , std::size_t N>
constexpr auto FNVa_a (const CharT(&s)[N], HashInt hval=fnv::fnv_offset< HashInt >::value) noexcept -> HashInt
 A templatized FNVa hash function, for raw character arrays, such as string literals. More...
 
constexpr auto FNV32a (std::string_view s, std::uint32_t hval=fnv::fnv_offset< std::uint32_t >::value) noexcept -> std::uint32_t
 A standard FNV32a hash function, for string_views. More...
 
template<typename HashInt >
constexpr auto FNVa_s (const char *begin, std::size_t length, HashInt hval=fnv::fnv_offset< HashInt >::value) noexcept -> HashInt
 
template<std::size_t N>
constexpr auto FNV32a_a (const char(&s)[N], std::uint32_t hval=fnv::fnv_offset< std::uint32_t >::value) noexcept -> std::uint32_t
 A standard FNV32a hash function, for raw character arrays, such as string literals. More...
 
constexpr auto FNV32a_s (const char *begin, std::size_t length, uint32_t hval=fnv::fnv_offset< std::uint32_t >::value) noexcept -> std::uint32_t
 
constexpr auto operator""_fnv32 (const char *str, std::size_t length) noexcept -> std::uint32_t
 A literal suffix that produces the FNV32a hash of a string literal. More...
 
constexpr auto operator""_fnv64 (const char *str, std::size_t length) noexcept -> std::uint64_t
 A literal suffix that produces the FNV64a hash of a string literal. More...
 
constexpr auto operator""_fnv32 (unsigned long long val) -> std::uint32_t
 
constexpr auto operator""_fnv64 (unsigned long long val) -> std::uint64_t
 
template<typename string = std::string>
auto toUTF8 (const icu::UnicodeString &s) -> string
 Convert a UnicodeString to a UTF-8 string. More...
 
template<typename string >
auto fromUTF8 (string s) -> icu::UnicodeString
 Convert a UTF-8 string into a UnicodeString. More...
 
template<typename string = std::u32string>
auto toUTF32 (const icu::UnicodeString &s) -> string
 Converts a UnicodeString to UTF-32. More...
 
template<typename string >
auto fromUTF32 (string s) -> icu::UnicodeString
 Converts a UTF-32 string into a UnicodeString. More...
 
template<typename T >
auto fromStr (const icu::UnicodeString &val, const char *type=typeid(T).name()) -> T
 Reencodes val to UTF-8 and then converts it to T using the primary overload. More...
 
template<typename D = std::string, typename std::enable_if_t< is_contiguous_v< D >, int > = 0>
auto get_contents (std::istream &in, D &out) -> auto
 
template<typename D = std::string, typename string >
auto get_file_contents (const string &filename) -> std::optional< D >
 Read the entire contents of a file into a container, such as std::string or std::vector<char>. Note that it will be most efficient to read into contiguous containers, as opposed to non-contiguous containers. More...
 
template<typename D = std::string, typename string >
auto try_get_file_contents (const string &filename) -> D
 Read the entire contents of a file into a container, such as std::string or std::vector<char>. Note that it will be most efficient to read into contiguous containers, as opposed to non-contiguous containers. More...
 
auto getline (std::istream &is) -> std::string
 By-value std::getline wrapper. More...
 
auto eat_word (std::istream &is) -> std::istream &
 Consume all non-spaces to first break, then eat that, too. More...
 
std::istream & eat_space (std::istream &is)
 Eat spaces, don't eat an extra. More...
 
template<typename CharT , typename Traits >
auto nl (std::basic_istream< CharT, Traits > &is) -> std::basic_istream< CharT, Traits > &
 Read in spaces until the end of the line is found. More...
 
template<typename CharT >
auto unformatted_expect (CharT c) -> auto
 Read a character from an input stream only if it equals c. Acts as an UnformattedInputOperation, that is, it will not ignore any leading whitespace. More...
 
template<typename CharT >
auto expect (CharT c) -> auto
 Read a character from an input stream only if it equals c. Acts as a FormattedInputOperation, that is, leading whitespace is ignored. More...
 
template<typename CharT , typename... O, template< typename, typename... > class string>
auto get_line (string< CharT, O... > &str) -> auto
 Read a whole line into a std::basic_string-like class template. More...
 
template<typename CharT , typename... O, template< typename, typename... > class string>
auto get_line (string< CharT, O... > &str, CharT delim) -> auto
 Read a delimited string into a std::basic_string-like class template. More...
 
template<typename F , typename CharT , typename Tr >
std::basic_istream< CharT, Tr > & operator>> (std::basic_istream< CharT, Tr > &is, get_manip< F > func)
 Actually calls the manipulator. More...
 
template<typename F , typename CharT , typename Tr >
std::basic_ostream< CharT, Tr > & operator<< (std::basic_ostream< CharT, Tr > &is, get_manip< F > func)
 Actually calls the manipulator. More...
 
template<typename StreamA , typename StreamB >
auto tee (StreamA &a, StreamB &b) -> basic_teestream< StreamA, StreamB >
 
template<typename File = std::fstream>
auto scoped_file (const std::filesystem::path &path, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
 
template<typename File = std::fstream>
auto tmpfile (const std::filesystem::path &path, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
 
template<typename P >
constexpr auto to_pointer (P &&p) noexcept -> auto *
 Gets a raw pointer out of any smart pointer or iterator you might pass in, without dereferencing it or relying on a get() method. More...
 
template<typename Container , typename Comp = std::less<value_type_linear_t<Container>>>
auto max_element (Container &c, Comp comp) -> value_type_linear_t< Container > *
 
template<typename C >
counting_back_insert_iterator< C > counting_back_inserter (C &c, std::size_t count=0)
 
template<typename T >
constexpr auto operator+ (T val, adjuster a) noexcept -> enable_if_t< not detail_iterators::is_addable< T, std::ptrdiff_t >::value, decltype(std::advance(val, a.adj))>
 
template<typename T >
constexpr auto operator+ (T val, incrementer) -> T
 Increments val. More...
 
template<typename T >
constexpr auto operator+ (T val, decrementer) -> T
 Decrements val. More...
 
template<typename Value , typename Delta = int>
constexpr auto range (Value min, Value max, Delta step=0) -> range_t< Value, Delta >
 Constructs a range from beginning, end, and step amount. The range is half-open, that is min is in the range but max is not. If unspecified, the step is automatically either 1 or -1, depending on whether max > min. More...
 
template<typename Value >
constexpr auto range (Value max) -> range_t< Value, incrementer >
 Constructs a half-open range [0, max). The step is automatically determined based on the sign of max. More...
 
template<typename Value , typename Delta = int>
constexpr auto irange (Value, Value, Delta=0)
 
template<std::size_t I, typename T >
auto get (enumeration< T > &&e) -> decltype(auto)
 
template<std::size_t I, typename T >
auto get (const enumeration< T > &&e) -> decltype(auto)
 
template<std::size_t I, typename T >
auto get (volatile enumeration< T > &e) -> decltype(auto)
 
template<std::size_t I, typename T >
auto get (const volatile enumeration< T > &e) -> decltype(auto)
 
template<typename It , typename EIt >
auto magic_enumerate (It begin, EIt end) -> enumerator_t< It, EIt >
 Allow access to indexes while using range-based for loops. More...
 
template<typename Range >
auto magic_enumerate (Range &&r) -> auto
 Allow access to indexes while using range-based for loops. Safe to use with rvalues. More...
 
template<typename Iter1 , typename Iter2 >
constexpr auto indirect (Iter1 begin, Iter2 end) noexcept(noexcept(indirect_range< Iter1, Iter2 >{begin, end})) -> indirect_range< Iter1, Iter2 >
 Create a range from an iterator pair. Primarily useful for range-for loops. More...
 
template<typename Iter1 , typename Iter2 >
 indirect_range (Iter1, Iter2) -> indirect_range< Iter1, Iter2 >
 
template<typename Iter1 , typename Iter2 >
auto cry_enumerate (Iter1 begin, Iter2 end) -> auto
 
template<typename It , typename operation >
 transform_iterator (It, operation) -> transform_iterator< It, operation >
 
template<typename base_iterator , typename operation >
auto make_transform_iterator (base_iterator it, operation op) noexcept(noexcept(transform_iterator< base_iterator, operation >{ it, std::move(op)})) -> transform_iterator< base_iterator, operation >
 Factory function to make transform_iterators. More...
 
template<typename base_iterator , typename operation >
auto transformer (base_iterator it, operation op) noexcept(noexcept(transform_iterator< base_iterator, operation >{it, std::move(op)})) -> transform_iterator< base_iterator, operation >
 Factory function to make transform_iterators. More...
 
template<typename It , typename EndIt , typename operation >
auto transform_range (It begin, EndIt end, operation op) noexcept(noexcept(indirect(transform_iterator{begin, op}, end))) -> auto
 
template<typename InputIt1 , typename EndIt , typename InputIt2 >
auto zip (InputIt1 begin1, EndIt end1, InputIt2 begin2) noexcept(zip_iterator< InputIt1, EndIt, InputIt2 >::is_nothrow_copyable) -> zip_iterator< InputIt1, EndIt, InputIt2 >
 Iterate over two ranges in lockstep, like Python's zip. More...
 
template<typename Range1 , typename Range2 >
auto zip (Range1 &&r1, Range2 &&r2) noexcept(zip_iterator< decltype(begin(r1)), decltype(end(r1)), decltype(begin(r2))>::is_nothrow_copyable) -> zip_iterator< decltype(begin(r1)), decltype(end(r1)), decltype(begin(r2))>
 Iterate over two ranges in lockstep, like Python's zip. More...
 
template<typename F >
auto consumer (F f) -> consume_iterator< F >
 Creates a consume_iterator of deduced type F. More...
 
template<typename T , typename Deleter >
auto make_cond_ptr (std::unique_ptr< T, Deleter > &&arg) noexcept -> cond_ptr< T, Deleter >
 
template<typename T >
auto make_cond_ptr (T *arg, bool owner=false) noexcept -> cond_ptr< T >
 
template<typename T , typename Deleter >
auto make_cond_ptr (T *arg, Deleter del) noexcept -> cond_ptr< T, Deleter >
 
template<typename T , typename Deleter >
auto make_cond_ptr (T *arg, bool owner, Deleter del) noexcept -> cond_ptr< T, Deleter >
 
constexpr auto operator| (construct_type l, construct_type r) noexcept -> construct_type
 
constexpr auto operator& (construct_type l, construct_type r) noexcept -> construct_type
 
constexpr auto operator* (construct_type l, bool r) noexcept -> construct_type
 
template<typename T >
auto noop (void *, const T *) -> T *
 Does nothing; matches the copy construction signature. More...
 
template<typename T , bool nothrow>
auto noop (void *, T *) noexcept(nothrow) -> T *
 Does nothing; matches the move construction signature. More...
 
template<bool warn>
constexpr auto poly_warn_if () -> std::nullptr_t
 
template<>
constexpr auto poly_warn_if< true > () -> std::nullptr_t
 
template<typename Array , typename RandomGenerator , typename freqtype = double>
auto chooseCategorical (Array &&cats, RandomGenerator &r) -> decltype(cats.size())
 Given a categorical distribution cats, selects one category. More...
 
template<typename Gen , typename Source >
auto seeded (Source &&s) -> Gen
 
template<typename Gen >
auto seeded () -> Gen
 
template<typename UIntType >
constexpr auto ipow2 (UIntType b) noexcept -> UIntType
 
template<typename F , typename... T>
auto map (F f, T &&... t) noexcept(noexcept(std::tuple{ kblib::apply(f, std::forward< T >(t))...})) -> enable_if_t< not any_void< decltype(kblib::apply(f, std::forward< T >(t)))... >, decltype(std::tuple{kblib::apply(f, std::forward< T >(t))...})>
 
template<typename F >
auto defer (F f)
 
template<typename BinaryOperation >
constexpr auto flip () -> auto
 Transforms a stateless binary operation into one which takes reversed arguments. More...
 
template<typename BinaryOperation >
constexpr auto flip (BinaryOperation op) -> auto
 Transforms a binary operation into one which takes reversed arguments. More...
 
template<typename T , std::size_t N>
constexpr auto is_consecutive (const T(&array)[N]) -> enable_if_t< std::is_integral< T >::value, bool >
 
constexpr auto filg2 (const std::bitset< std::numeric_limits< std::uintmax_t >::digits > val) noexcept -> int
 Floored integer binary logarithm. Returns floor(lb(val)). More...
 
template<typename T >
auto safe_auto (T &&in) -> T
 Safely propagate an xvalue or lvalue without dangling references. More...
 
template<typename T >
auto safe_auto (T &in) -> T &
 Safely propagate an xvalue or lvalue without dangling references. More...
 
template<typename LeftContainer , typename RightContainer >
auto arraycat (LeftContainer A, RightContainer &&B) noexcept(noexcept(A.insert(A.end(), B.begin(), B.end()))) -> LeftContainer
 Concatenate two dynamic containers together. More...
 
template<typename T >
constexpr auto a (const std::initializer_list< T > &a) -> auto
 Index an array literal without naming its type. More...
 
template<typename RandomAccessIt , typename Compare = std::less<>>
constexpr auto insertion_sort (const RandomAccessIt begin, const RandomAccessIt end, Compare &&compare={}) noexcept(noexcept(swap(*begin, *begin)) and noexcept(compare(*begin, *begin))) -> void
 In-place insertion sort. As is usual, it is stable. Provides as a guarantee that it will perform no moves on sorted input. More...
 
template<typename RandomAccessIt , typename RandomAccessIt2 , typename Compare = std::less<>>
constexpr auto insertion_sort_copy (const RandomAccessIt begin, const RandomAccessIt end, const RandomAccessIt2 d_begin, const RandomAccessIt2 d_end, Compare &&compare={}) noexcept(noexcept(detail_algorithm::shift_backward(d_begin, d_begin, d_end)) and noexcept(*d_begin= *begin)) -> void
 Out-of-place insertion sort, which does not modify the input. Provides as a guarantee that it will perform no moves on sorted input. More...
 
template<typename RandomAccessIt , typename RandomAccessIt2 , typename Compare = std::less<>>
constexpr auto adaptive_insertion_sort_copy (const RandomAccessIt begin, const RandomAccessIt end, const RandomAccessIt2 d_begin, const RandomAccessIt2 d_end, Compare &&compare={}) noexcept(noexcept(detail_algorithm::shift_backward(d_begin, d_begin, d_end)) and noexcept(*d_begin= *begin)) -> void
 An adaptive sort which, at the cost of some additional work (time complexity Θ(sqrt(n))), avoids quadratic behavior for reverse-sorted inputs (and, in fact, handles them in optimal time). It's still possible to fool it, but it requires a staggered input, which is a highly unlikely shape for random data. More...
 
template<typename T >
constexpr auto byte_count (T) noexcept -> enable_if_t< std::is_integral< T >::value, std::size_t >
 
template<typename T >
constexpr auto byte_count (T *) noexcept -> std::size_t
 
template<typename T >
constexpr auto byte_count (const std::unique_ptr< T > &) noexcept -> std::size_t
 
template<typename T >
constexpr auto byte_count (const T &x) noexcept -> enable_if_t< is_linear_container_v< T > and(std::is_integral< typename T::value_type >::value or is_byte_v< T >) and sizeof(typename T::value_type)==1, std::size_t >
 
constexpr auto byte_count (...) -> void=delete
 
template<typename T >
constexpr auto get_byte_index (T x, std::size_t idx) noexcept -> enable_if_t< std::is_integral< T >::value, unsigned char >
 
template<typename T >
constexpr auto get_byte_index (const T &x, std::size_t idx) noexcept -> enable_if_t< std::is_enum< T >::value, unsigned char >
 
template<typename T >
auto get_byte_index (T *x, std::size_t idx) noexcept -> unsigned char
 
template<typename T >
auto get_byte_index (const std::unique_ptr< T > &x, std::size_t idx) noexcept -> unsigned char
 
template<typename RandomAccessIt , typename UnaryOperation , typename BinaryPredicate >
constexpr auto sort_transform (RandomAccessIt begin, RandomAccessIt end, UnaryOperation &&transform, BinaryPredicate &&compare) -> void
 Sorts a range after applying a transformation. More...
 
template<typename RandomAccessIt , typename UnaryOperation >
constexpr auto sort_transform (RandomAccessIt begin, RandomAccessIt end, UnaryOperation &&transform) -> void
 
template<typename RandomAccessIt , typename BinaryPredicate >
constexpr auto sort (RandomAccessIt begin, RandomAccessIt end, BinaryPredicate &&compare) -> void
 Sorts a range. More...
 
template<typename RandomAccessIt >
constexpr auto sort (RandomAccessIt begin, RandomAccessIt end) -> void
 
template<typename T , typename U >
constexpr auto div (T num, U den) noexcept -> decltype(std::div(num, den))
 
template<typename U >
constexpr auto calc_fib_size () noexcept -> std::size_t
 Calculate the index of the largest fibonacci number that can be represented by a given unsigned integral type. More...
 
template<typename U , std::size_t N = calc_fib_size<U>() + 1>
constexpr auto make_fib_arr () noexcept -> trivial_array< U, N >
 Generates the first N values of the fibonacci sequence. More...
 
template<typename U = std::uintmax_t>
constexpr auto fibonacci (int n) noexcept -> U
 Compile-time table fibonacci function. More...
 
template<typename T >
auto operator== (T t, max_t) -> bool
 
template<typename T >
auto operator== (max_t, T t) -> bool
 
template<typename T >
auto operator!= (T t, max_t) -> bool
 
template<typename T >
auto operator!= (max_t, T t) -> bool
 
template<typename T >
auto operator< (T t, max_t) -> bool
 
template<typename T >
auto operator< (max_t, T t) -> bool
 
template<typename T >
auto operator> (T t, max_t) -> bool
 
template<typename T >
auto operator> (max_t, T t) -> bool
 
template<typename T >
auto operator<= (T t, max_t) -> bool
 
template<typename T >
auto operator<= (max_t, T t) -> bool
 
template<typename T >
auto operator>= (T t, max_t) -> bool
 
template<typename T >
auto operator>= (max_t, T t) -> bool
 
template<typename T >
auto operator== (T t, min_t) -> bool
 
template<typename T >
auto operator== (min_t, T t) -> bool
 
template<typename T >
auto operator!= (T t, min_t) -> bool
 
template<typename T >
auto operator!= (min_t, T t) -> bool
 
template<typename T >
auto operator< (T t, min_t) -> bool
 
template<typename T >
auto operator< (min_t, T t) -> bool
 
template<typename T >
auto operator> (T t, min_t) -> bool
 
template<typename T >
auto operator> (min_t, T t) -> bool
 
template<typename T >
auto operator<= (T t, min_t) -> bool
 
template<typename T >
auto operator<= (min_t, T t) -> bool
 
template<typename T >
auto operator>= (T t, min_t) -> bool
 
template<typename T >
auto operator>= (min_t, T t) -> bool
 
template<typename T >
constexpr auto pi () -> T
 
template<typename T >
constexpr auto tau () -> T
 
template<typename T >
constexpr auto e () -> T
 
template<typename T >
constexpr auto root_2 () -> T
 
template<typename T >
constexpr auto phi () -> T
 
template<typename A , typename F >
constexpr auto saturating_cast (F x) noexcept -> enable_if_t< std::is_integral< A >::value and std::is_integral< F >::value and std::is_unsigned< A >::value, A >
 
template<typename T , typename F >
constexpr auto quantize_step (F low, F delta, F val) noexcept -> T
 Quantize a real-valued value into a discrete integer. More...
 
template<typename T , typename F >
constexpr auto quantize_range (F low, F high, F val) noexcept -> T
 Quantize a real-valued value into a discrete integer. More...
 
template<typename Container = std::vector<std::string>, typename Predicate , typename String >
auto split_tokens (const String &in, Predicate spacer) -> return_assert_t< is_callable< Predicate, typename Container::value_type::value_type >::value, Container >
 Split a string on all condensed delimiters. More...
 
template<typename Container = std::vector<std::string>, typename String >
auto split_tokens (const String &in) -> Container
 Split a string on all instances of whitespace. More...
 
template<typename Container = std::vector<std::string>, typename String >
auto split_tokens (const String &in, typename Container::value_type::value_type delim) -> Container
 Split a string on all instances of a delimiter. More...
 
template<typename Container = std::vector<std::string>, typename String >
auto kbsplit2 (const String &in, char delim=' ') -> Container
 
template<typename Container = std::vector<std::string>, typename String >
auto split_dsv (const String &str, char delim) -> Container
 Split a string on all instances of delim. More...
 
template<typename Container = std::vector<std::string>, typename String , typename Predicate >
auto split_dsv (const String &str, Predicate delim) -> return_assert_t< is_callable< Predicate, typename Container::value_type::value_type >::value, Container >
 Split a string on all instances of delim. More...
 
template<typename string >
auto reverse_str (string val) -> string
 Reverses all the elements of its input. More...
 
template<typename string >
constexpr auto tolower (string str) -> string
 Folds all characters in a string using the default execution character set to lowercase. More...
 
template<typename string >
auto toupper (string str) -> string
 Folds all characters in a string using the default execution character set to uppercase. More...
 
template<typename string >
auto repeat (string val, std::size_t count) -> string
 Construct a string consisting of count copies of val concatenated together. More...
 
auto repeat (char val, std::size_t count) -> std::string
 Construct a string consisting of count copies of val. More...
 
template<int trim, typename T , int N, typename Indices = std::make_integer_sequence<int, N - trim>>
constexpr auto trim_array (const T(&arr)[N]) -> std::array< T, N - trim >
 Truncates the last trim elements from an array. More...
 
template<int N, typename Indices = std::make_integer_sequence<int, N - 1>>
constexpr auto remove_null_terminator (const char(&arr)[N]) -> std::array< char, N - 1 >
 Creates an array of only the meaningful characters in a string literal, and not the null terminator. More...
 
template<typename T , typename F >
auto byte_cast (F v) noexcept -> T
 Creates a T with the same object representation as the given F. More...
 
template<typename C , typename std::enable_if< has_reserve_v< C >, int >::type = 0>
auto try_reserve (C &c, std::size_t s) noexcept(noexcept(c.reserve(s))) -> void
 Attempt to reserve capacity in a container. No-op if unsupported. More...
 
template<typename To , typename... Ts>
auto coerce (const std::variant< Ts... > &v) -> To
 Lexically converts the value of v (no matter its type) to type To. More...
 
template<typename To , typename... Ts>
auto static_coerce (const std::variant< Ts... > &v) -> To
 static_casts the value of v (no matter its type) to type To. More...
 
template<typename To , typename... Ts>
auto lexical_coerce (const std::variant< Ts... > &v) -> To
 Lexically converts the value of v (no matter its type) to type To. More...
 
template<typename... Ts>
 visitor (Ts...) -> visitor< Ts... >
 
template<typename Variant , typename... Fs>
constexpr auto visit_indexed (Variant &&variant, Fs &&... fs) -> decltype(auto)
 Visit a variant, but pass the index (as an integral_constant) to the visitor. This allows for a visitor of a variant with duplicated types to maintain index information. More...
 
template<typename To , typename From >
constexpr auto variant_cast (From &&v) -> To
 Promotes an input variant to a super-variant. That is, one which provides at least the same set of types. More...
 
template<typename V , typename F , typename... Fs>
constexpr auto visit (V &&v, F &&f, Fs &&... fs) -> decltype(auto)
 Wraps std::visit to provide an interface taking one variant and any number of functors providing an overload set. More...
 
template<typename V , typename F , typename... Fs>
constexpr auto visit2 (V &&v, F &&f, Fs &&... fs) -> decltype(auto)
 
template<typename V , typename F , typename... Fs>
constexpr auto visit2_nop (V &&v, F &&f, Fs &&... fs) -> void
 
template<typename V >
constexpr auto visit (V &v) -> auto
 Two-step visiting interface. Takes a variant, and returns an object which can be called with any number of callable arguments, builds an overload set from them, and visits the variant. More...
 

Variables

template<typename Int >
constexpr int bits_of = std::numeric_limits<Int>::digits
 
constexpr struct kblib::build_end_t build_end
 
struct {
swap
 
template<typename T >
constexpr bool value_detected_v = value_detected<T>::value
 
template<typename T >
constexpr bool key_detected_v = key_detected<T>::value
 
template<typename T >
constexpr bool mapped_detected_v = mapped_detected<T>::value
 
template<typename T >
constexpr bool hash_detected_v = hash_detected<T>::value
 
constexpr struct kblib::in_place_agg_t in_place_agg
 
template<typename T >
constexpr int padding_bits_v = padding_bits<T>::value
 
template<typename Key >
KBLIB_CONSTANT_V is_hashable_v = is_hashable<Key>::value
 
template<typename T >
KBLIB_CONSTANT_V is_trivially_hashable_v
 
template<bool A, bool B>
constexpr bool implies_v = implies<A, B>::value
 
template<bool... args>
constexpr bool conjunction_v = (args and ...)
 
template<typename T >
constexpr std::size_t state_size_v = state_size<T>::value
 
template<typename... Ts>
constexpr bool any_void = (std::is_void_v<Ts> or ...)
 
template<typename T >
constexpr bool is_radix_sortable_v = is_radix_sortable<T>::value
 
template<typename T >
constexpr bool is_byte_v = false
 
constexpr struct kblib::nums::max_t max
 
constexpr struct kblib::nums::min_t min
 
constexpr endian system_endian = endian::unknown
 
constexpr endian hash_order = detail::get_hash_order()
 
template<typename... Ts>
KBLIB_CONSTANT_V contains_type_v = contains_type<Ts...>::value
 
template<typename... Ts>
KBLIB_CONSTANT_V contains_types_v = contains_types<Ts...>::value
 
template<typename C >
KBLIB_CONSTANT_V is_resizable_v = decltype(detail::calc_resizable<C>(0))::value
 
template<typename C , typename = void>
KBLIB_CONSTANT_V has_reserve_v = false
 
template<typename C , typename = void>
KBLIB_CONSTANT_V is_contiguous_v = false
 Type trait to determine if a container is contiguous. More...
 
template<typename T >
KBLIB_CONSTANT_V is_input_iterator_v = is_input_iterator<T>::value
 
template<typename T >
KBLIB_CONSTANT_V is_forward_iterator_v = is_forward_iterator<T>::value
 
template<typename T >
KBLIB_CONSTANT_V is_bidirectional_iterator_v = is_bidirectional_iterator<T>::value
 
template<typename T >
KBLIB_CONSTANT_V is_random_access_iterator_v = is_random_access_iterator<T>::value
 
template<typename T >
KBLIB_CONSTANT_V is_iterable_v = is_iterable<T>::value
 
template<typename T >
KBLIB_CONSTANT_V is_iterator_v = is_iterator<T>::value
 
template<typename T >
KBLIB_CONSTANT_V is_reference_v = std::is_reference<T>::value
 Abbreviated name for std::is_reference<T>::value for C++14. More...
 
template<typename CharT = char>
KBLIB_CONSTANT auto eof = std::char_traits<CharT>::eof()
 Names the EOF value for the given character type in std::char_traits. More...
 
template<typename T >
KBLIB_CONSTANT_V is_aliasing_type_v = is_aliasing_type<T>::value
 
template<typename T , typename = void>
constexpr bool is_variant_like_v = false
 

Detailed Description

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

Typedef Documentation

◆ alias

template<typename T >
using kblib::alias = typedef T

A simple identity alias for simplifying some compound type declarations, such as function pointers.

Definition at line 155 of file traits.h.

◆ bool_constant

template<bool v>
using kblib::bool_constant = typedef std::integral_constant<bool, v>

Definition at line 64 of file fakestd.h.

◆ class_of_t

template<typename T >
using kblib::class_of_t = typedef typename class_of<T>::type

Definition at line 279 of file traits.h.

◆ copy_const_t

template<typename C , typename V >
using kblib::copy_const_t = typedef typename copy_const<C, V>::type

Definition at line 870 of file fakestd.h.

◆ decay_t

template<typename T >
using kblib::decay_t = typedef typename std::decay<T>::type

Definition at line 57 of file fakestd.h.

◆ enable_if_t

template<bool B, typename T = void>
using kblib::enable_if_t = typedef typename std::enable_if<B, T>::type

Definition at line 54 of file fakestd.h.

◆ FNV32_hash

template<typename Key >
using kblib::FNV32_hash = typedef FNV_hash<Key, std::uint32_t>

Definition at line 331 of file hash.h.

◆ hash_detected_t

template<typename T >
using kblib::hash_detected_t = typedef typename hash_detected<T>::type

Definition at line 922 of file fakestd.h.

◆ hash_map

template<typename Key , typename Value >
using kblib::hash_map = typedef std::unordered_map<Key, Value, FNV_hash<Key> >

Definition at line 736 of file hash.h.

◆ hash_multimap

template<typename Key , typename Value >
using kblib::hash_multimap = typedef std::unordered_multimap<Key, Value, FNV_hash<Key> >

Definition at line 738 of file hash.h.

◆ hash_multiset

template<typename T , typename HashInt >
using kblib::hash_multiset = typedef std::unordered_set<T, FNV_hash<T> >

Definition at line 742 of file hash.h.

◆ hash_set

template<typename T , typename HashInt >
using kblib::hash_set = typedef std::unordered_set<T, FNV_hash<T> >

Definition at line 740 of file hash.h.

◆ ignore_t

template<typename U , typename T >
using kblib::ignore_t = typedef typename ignore<U, T>::type

An alias for ignore<U, T>::type.

Definition at line 169 of file traits.h.

◆ int_smallest

template<std::uintmax_t I>
using kblib::int_smallest = typedef typename first_bigger_than<1 + (filg2(I) + 1) / CHAR_BIT, signed char, signed short, signed int, signed long, signed long long, std::uintmax_t>::type

Definition at line 172 of file simple.h.

◆ int_smallest_t

template<std::uintmax_t I>
using kblib::int_smallest_t = typedef typename int_smallest<I>::type

Definition at line 181 of file simple.h.

◆ iterator_type_for_t

template<typename Range >
using kblib::iterator_type_for_t = typedef typename iterator_type_for<Range>::type

Definition at line 400 of file traits.h.

◆ key_detected_t

template<typename T >
using kblib::key_detected_t = typedef typename key_detected<T>::type

Definition at line 896 of file fakestd.h.

◆ key_type_setlike_t

template<typename Container >
using kblib::key_type_setlike_t = typedef typename key_type_setlike<Container>::type

Definition at line 951 of file fakestd.h.

◆ mapped_detected_t

template<typename T >
using kblib::mapped_detected_t = typedef typename mapped_detected<T>::type

Definition at line 909 of file fakestd.h.

◆ member_of_t

template<typename T >
using kblib::member_of_t = typedef typename member_of<T>::type

Definition at line 304 of file traits.h.

◆ meta_type_t

template<typename... Ts>
using kblib::meta_type_t = typedef typename meta_type<Ts...>::type

Definition at line 504 of file fakestd.h.

◆ metafunction_value_t

template<typename T >
using kblib::metafunction_value_t = typedef std::integral_constant<decltype(T::value), T::value>

Definition at line 528 of file fakestd.h.

◆ move_only_traits

template<typename Obj >
using kblib::move_only_traits = typedef poly_obj_traits<Obj, construct_type::move>

Definition at line 449 of file poly_obj.h.

◆ no_move_traits

template<typename Obj >
using kblib::no_move_traits = typedef poly_obj_traits<Obj, construct_type::none>

Definition at line 451 of file poly_obj.h.

◆ remove_cvref_t

template<typename T >
using kblib::remove_cvref_t = typedef typename std::remove_reference<typename std::remove_cv<T>::type>::type

Definition at line 60 of file fakestd.h.

◆ remove_reference_t

template<typename T >
using kblib::remove_reference_t = typedef typename std::remove_reference<T>::type

Abbreviated name for std::remove_reference<T>::type for C++14.

Definition at line 441 of file traits.h.

◆ return_assert_t

template<bool V, typename T >
using kblib::return_assert_t = typedef typename return_assert<V, T>::type

Definition at line 542 of file fakestd.h.

◆ safe_signed_t

template<typename N >
using kblib::safe_signed_t = typedef typename safe_signed<N>::type

Definition at line 846 of file fakestd.h.

◆ uint_smallest

template<std::uintmax_t I>
using kblib::uint_smallest = typedef typename first_bigger_than<1 + filg2(I) / CHAR_BIT, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, std::uintmax_t>::type

Definition at line 166 of file simple.h.

◆ uint_smallest_t

template<std::uintmax_t I>
using kblib::uint_smallest_t = typedef typename uint_smallest<I>::type

Definition at line 178 of file simple.h.

◆ value_detected_t

template<typename T >
using kblib::value_detected_t = typedef typename value_detected<T>::type

Definition at line 883 of file fakestd.h.

◆ value_type_linear_t

template<typename Container >
using kblib::value_type_linear_t = typedef typename value_type_linear<Container>::type

Definition at line 933 of file fakestd.h.

◆ void_if_t

template<bool b>
using kblib::void_if_t = typedef typename void_if<b>::type

Definition at line 512 of file fakestd.h.

Enumeration Type Documentation

◆ construct_type

enum kblib::construct_type : unsigned
strong
Enumerator
none 
copy_only 
move 
both 
throw_move 
both_throw 

Definition at line 40 of file poly_obj.h.

◆ endian

enum kblib::endian
strong
Enumerator
unknown 
little 
big 
weird 

Definition at line 164 of file tdecl.h.

◆ extractor_policy

Enumerator
forward_iteration 
random_access 

Definition at line 39 of file trie.h.

Function Documentation

◆ a()

template<typename T >
constexpr auto kblib::a ( const std::initializer_list< T > &  a) -> auto
constexpr

Index an array literal without naming its type.

Attention
The return value must not be stored unless the argument is also stored. This is indexable because temporaries live until the end of their full-expression, rather than sub-expression
Parameters
aThe array literal to index into.

Definition at line 233 of file simple.h.

◆ accumulate() [1/2]

template<typename InputIt , typename T >
constexpr auto kblib::accumulate ( InputIt  first,
InputIt  last,
init 
) -> T
constexpr

A constexpr version of std::accumulate.

Definition at line 162 of file algorithm.h.

◆ accumulate() [2/2]

template<class InputIt , class T , class BinaryOperation >
constexpr auto kblib::accumulate ( InputIt  first,
InputIt  last,
init,
BinaryOperation  op 
) -> T
constexpr

A constexpr version of std::accumulate.

Definition at line 174 of file algorithm.h.

◆ adaptive_insertion_sort_copy()

template<typename RandomAccessIt , typename RandomAccessIt2 , typename Compare = std::less<>>
constexpr auto kblib::adaptive_insertion_sort_copy ( const RandomAccessIt  begin,
const RandomAccessIt  end,
const RandomAccessIt2  d_begin,
const RandomAccessIt2  d_end,
Compare &&  compare = {} 
) -> void
constexprnoexcept

An adaptive sort which, at the cost of some additional work (time complexity Θ(sqrt(n))), avoids quadratic behavior for reverse-sorted inputs (and, in fact, handles them in optimal time). It's still possible to fool it, but it requires a staggered input, which is a highly unlikely shape for random data.

Remarks
Complexity:
Average case O(n^2)
Best-case Θ(n + sqrt(n)) (for sorted input)
worst-case O(n^2) (for reverse-sorted input)
Parameters
begin,endThe input range
d_begin,d_endThe output range
compareThe comparison predicate

Definition at line 178 of file sort.h.

◆ all_of() [1/2]

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>
constexpr

Determine if pred is true for every element of the range.

Definition at line 970 of file algorithm.h.

◆ all_of() [2/2]

template<typename Range , typename UnaryPredicate >
constexpr auto kblib::all_of ( Range &&  rng,
UnaryPredicate  pred 
) -> enable_if_t<is_iterable<Range>::value, bool>
constexpr

Determine if pred is true for every element of the range.

Definition at line 984 of file algorithm.h.

◆ any_of() [1/2]

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>
constexpr

Determine if pred is true for at least one element of the range.

Definition at line 1024 of file algorithm.h.

◆ any_of() [2/2]

template<typename Range , typename UnaryPredicate >
constexpr auto kblib::any_of ( Range &&  rng,
UnaryPredicate  pred 
) -> enable_if_t<is_iterable<Range>::value, bool>
constexpr

Determine if pred is true for every element of the range.

Definition at line 1038 of file algorithm.h.

◆ apply()

template<typename F , typename Arg >
constexpr auto kblib::apply ( F &&  f,
Arg &&  arg 
) -> decltype(auto)
constexprnoexcept

Definition at line 561 of file fakestd.h.

◆ arraycat()

template<typename LeftContainer , typename RightContainer >
auto kblib::arraycat ( LeftContainer  A,
RightContainer &&  B 
) -> LeftContainer
noexcept

Concatenate two dynamic containers together.

Parameters
A,BThe containers to concatenate together.
Returns
Container A container consisting of the elements of A and B in that order.

Definition at line 217 of file simple.h.

◆ build() [1/6]

template<typename Container , typename Functor >
auto kblib::build ( Functor  f,
size_t  size,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container

Constructs a container with elements initialized by repeatedly calling a generating function.

Template Parameters
ContainerThe type of container to return. Must be an AllocatorAware SequenceContainer.
Parameters
fThe functor to repeatedly invoke.
sizeThe number of times to invoke f.
allocatorThe allocator to use for the returned container.
Returns
A Container where each element is the result of invoking f in sequence.

Definition at line 168 of file build.h.

◆ build() [2/6]

template<typename Array , typename Functor , enable_if_t< not is_resizable_v< Array >, int > = 0>
auto kblib::build ( Functor  f,
size_t  size = std::tuple_size<Array>::value 
) -> Array

Constructs an array-like container with elements initialized by repeatedly calling a generating function.

Remarks
Because Array is non-resizable, the entire Array will be default-constructed and then the elements assigned to, rather than copy-constructed.
Template Parameters
ArrayThe type of container to return. Must be a non-resizable Container similar to std::array.
Parameters
fThe functor to repeatedly invoke.
sizeThe number of times to invoke f. Defaults to the size of the Container, which is usually correct.
Returns
An Array where each element is the result of invoking f in sequence.

Definition at line 195 of file build.h.

◆ build() [3/6]

template<typename Array , typename InputIt , typename InputIt2 , typename BinaryFunction , enable_if_t< not is_resizable_v< Array >, int > = 0>
auto kblib::build ( InputIt  first,
InputIt  last,
InputIt2  first2,
BinaryFunction  f 
) -> Array

Constructs an array-like container by applying a BinaryFunction to every pair of elements in the input ranges.

Precondition
The size of the second input range must be equal to or less than the size of the first.
Remarks
Because Array is non-resizable, the entire Array will be default-constructed and then the elements assigned to, rather than copy-constructed.
Parameters
firstBeginning of input range.
lastEnd of input range.
first2Beginning of second input range
fA BinaryFunction to apply to the elements of the two input ranges.
Template Parameters
ArrayThe type of container to return. Must be a non-resizable Container similar to std::array.
Returns
An Array where each element is generated from a corresponding pair of elements in the input ranges.

Definition at line 148 of file build.h.

◆ build() [4/6]

template<typename Container , typename InputIt , typename InputIt2 , typename BinaryFunction >
auto kblib::build ( InputIt  first,
InputIt  last,
InputIt2  first2,
BinaryFunction  f,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container

Constructs a container by applying a BinaryFunction to every pair of elements in the input ranges.

Precondition
The size of the second input range must be equal to or less than the size of the first.
Parameters
firstBeginning of input range.
lastEnd of input range.
first2Beginning of second input range
fA BinaryFunction to apply to the elements of the two input ranges.
Template Parameters
ContainerThe type of container to return. Must be an AllocatorAware SequenceContainer.
Parameters
allocatorThe allocator to use for the returned container.
Returns
A Container where each element is generated from a corresponding pair of elements in the input ranges.

Definition at line 92 of file build.h.

◆ build() [5/6]

template<typename Array , typename InputIt , typename UnaryFunction , enable_if_t< not is_resizable_v< Array >, int > = 0>
auto kblib::build ( InputIt  first,
InputIt  last,
UnaryFunction  f 
) -> Array

Constructs an array-like container by applying a UnaryFunction to every element of an input range.

Precondition
The size of the input range must be equal to or less than the size of Container.
Remarks
Because Array is non-resizable, the entire Array will be default-constructed and then the elements assigned to, rather than copy-constructed.
Parameters
firstBeginning of input range.
lastEnd of input range.
fA UnaryFunction to apply to each element of the input range.
Template Parameters
ArrayThe type of container to return. Must be a non-resizable Container similar to std::array.
Returns
An Array where each element is a transformed element of the input range.

Definition at line 121 of file build.h.

◆ build() [6/6]

template<typename Container , typename InputIt , typename UnaryFunction >
auto kblib::build ( InputIt  first,
InputIt  last,
UnaryFunction  f,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container

Constructs a container by applying a UnaryFunction to every element of an input range.

Parameters
firstBeginning of input range.
lastEnd of input range.
fA UnaryFunction to apply to each element of the input range.
Template Parameters
ContainerThe type of container to return. Must be an AllocatorAware SequenceContainer.
Parameters
allocatorThe allocator to use for the returned container.
Returns
A Container where each element is a transformed element of the input range.

Definition at line 66 of file build.h.

◆ build_copy() [1/7]

template<typename Container , typename InputIt , enable_if_t< not is_resizable_v< Container >, int > = 0>
constexpr auto kblib::build_copy ( InputIt  first,
InputIt  last 
) -> Container
constexpr
Parameters
first
last
Returns
Container

Definition at line 491 of file build.h.

◆ build_copy() [2/7]

template<typename Container , typename InputIt , enable_if_t< not is_resizable_v< Container >, int > = 0>
auto kblib::build_copy ( InputIt  first,
InputIt  last,
std::size_t  size 
) -> Container
Parameters
first
last
size
Returns
Container

Definition at line 532 of file build.h.

◆ build_copy() [3/7]

template<typename Container , typename InputIt >
auto kblib::build_copy ( InputIt  first,
InputIt  last,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container
Parameters
first
last
allocator
Returns
Container

Definition at line 439 of file build.h.

◆ build_copy() [4/7]

template<typename Container , typename Range , enable_if_t< is_resizable_v< Container >, int > = 0>
auto kblib::build_copy ( Range &&  r) -> Container
Parameters
r
allocator
Returns
Container

Definition at line 457 of file build.h.

◆ build_copy() [5/7]

template<typename Container , typename Range , enable_if_t< not is_resizable_v< Container >, int > = 0>
constexpr auto kblib::build_copy ( Range &&  r) -> Container
constexpr
Parameters
r
Returns
Container

Definition at line 510 of file build.h.

◆ build_copy() [6/7]

template<typename Container , typename Range , enable_if_t< not is_resizable_v< Container >, int > = 0>
auto kblib::build_copy ( Range &&  r,
std::size_t  size 
) -> Container
Parameters
r
size
Returns
Container

Definition at line 553 of file build.h.

◆ build_copy() [7/7]

template<typename Container , typename Range >
auto kblib::build_copy ( Range &&  r,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container
Parameters
r
allocator
Returns
Container

Definition at line 473 of file build.h.

◆ build_copy_if()

template<typename Container , typename InputIt , typename Predicate >
auto kblib::build_copy_if ( InputIt  first,
InputIt  last,
Predicate  f,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container
Parameters
first
last
f
allocator
Returns
Container

Definition at line 576 of file build.h.

◆ build_copy_n()

template<typename Container , typename InputIt , typename Size >
auto kblib::build_copy_n ( InputIt  first,
Size  count,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container
Parameters
first
count
allocator
Returns
Container

Definition at line 594 of file build.h.

◆ build_copy_n_if()

template<typename Container , typename InputIt , typename Size , typename Predicate >
auto kblib::build_copy_n_if ( InputIt  first,
Size  count,
Predicate  f,
typename Container::allocator_type  allocator = typename Container::allocator_type{} 
) -> Container
Parameters
first
count
f
allocator
Returns
Container

Definition at line 614 of file build.h.

◆ build_dy() [1/4]

template<typename Container , typename Functor >
auto kblib::build_dy ( Functor  f,
size_t  size 
) -> Container

Constructs a container with elements initialized by repeatedly calling a generating function. Exactly like build, but for resizable non-AllocatorAware Containers (which are hard to detect automatically).

Parameters
fThe functor to repeatedly invoke.
sizeThe number of times to invoke f.
Returns
A Container where each element is the result of invoking f in sequence.

Definition at line 260 of file build.h.

◆ build_dy() [2/4]

template<typename Container , typename InputIt , typename InputIt2 , typename BinaryFunction >
auto kblib::build_dy ( InputIt  first,
InputIt  last,
InputIt2  first2,
BinaryFunction  f 
) -> Container

Constructs a container by applying a BinaryFunction to every pair of elements in the input ranges. Exactly like build, but for resizable non-AllocatorAware Containers (which are hard to detect automatically).

Precondition
The size of the second input range must be equal to or less than the size of the first.
Parameters
firstBeginning of input range.
lastEnd of input range.
first2Beginning of second input range
fA BinaryFunction to apply to the elements of the two input ranges.
Template Parameters
ContainerThe type of container to return. Must be a resizable SequenceContainer.
Returns
A Container where each element is generated from a corresponding pair of elements in the input ranges.

Definition at line 242 of file build.h.

◆ build_dy() [3/4]

template<typename Container , typename InputIt , typename UnaryFunction >
auto kblib::build_dy ( InputIt  first,
InputIt  last,
UnaryFunction  f 
) -> Container

Constructs a container by applying a UnaryFunction to every element of an input range. Exactly like build, but for resizable non-AllocatorAware Containers (which are hard to detect automatically).

Parameters
firstBeginning of input range.
lastEnd of input range.
fA UnaryFunction to apply to each element of the input range.
Template Parameters
ContainerThe type of container to return. Must be a resizable SequenceContainer.
Returns
A Container where each element is a transformed element of the input range.

Definition at line 218 of file build.h.

◆ build_dy() [4/4]

template<typename Container , typename Range , typename UnaryFunction , enable_if_t< is_resizable_v< Container >, int > = 0>
auto kblib::build_dy ( Range &&  r,
UnaryFunction  f 
) -> Container
Parameters
r
allocator
Returns
Container

Definition at line 276 of file build.h.

◆ buildiota()

template<typename Container , typename... Args>
constexpr auto kblib::buildiota ( Args &&...  args) -> auto
constexpr

Builds a container of increasing values.

Template Parameters
ContainerEither a resizable (like std::vector) or non-resizable (like std::array) Container.
Remarks
If Container is non-resizable, then elements are first value-initialized and then assigned to, otherwise values are inserted directly.
Parameters
argsIf Container is resizable, the first argument is the size of container to return, otherwise there is no size argument. The next argument is always the starting value. Optionally, an increment may be specified as a final argument.

Definition at line 425 of file build.h.

◆ byte_cast()

template<typename T , typename F >
auto kblib::byte_cast ( v) -> T
noexcept

Creates a T with the same object representation as the given F.

T and F must be the same size and must both be trivially copyable.

Note
Will be fully replaceable by std::bit_cast in C++20.
Parameters
vA value to reinterpret.
Returns
T The reinterpreted value.

Definition at line 182 of file traits.h.

◆ byte_count() [1/5]

constexpr auto kblib::byte_count (   ...) -> void=delete
constexprdelete

◆ byte_count() [2/5]

template<typename T >
constexpr auto kblib::byte_count ( const std::unique_ptr< T > &  ) -> std::size_t
constexprnoexcept

Definition at line 271 of file sort.h.

◆ byte_count() [3/5]

template<typename T >
constexpr auto kblib::byte_count ( const T &  x) -> enable_if_t< is_linear_container_v< T> and (std::is_integral<typename T::value_type>::value or is_byte_v<T>) and sizeof(typename T::value_type) == 1, std::size_t>
constexprnoexcept

Definition at line 276 of file sort.h.

◆ byte_count() [4/5]

template<typename T >
constexpr auto kblib::byte_count ( T *  ) -> std::size_t
constexprnoexcept

Definition at line 267 of file sort.h.

◆ byte_count() [5/5]

template<typename T >
constexpr auto kblib::byte_count ( ) -> enable_if_t<std::is_integral<T>::value, std::size_t>
constexprnoexcept

Definition at line 252 of file sort.h.

◆ calc_fib_size()

template<typename U >
constexpr auto kblib::calc_fib_size ( ) -> std::size_t
constexprnoexcept

Calculate the index of the largest fibonacci number that can be represented by a given unsigned integral type.

Remarks
Here is a table of the results for common bit-widths:
bits  N    fibonacci(N)
--------------------------------------------------
8     13   144
16    24   28657
32    47   1836311903
64    93   7540113804746346429
128   186  205697230343233228174223751303346572685
Returns
std::size_t

Definition at line 132 of file stats.h.

◆ calculate_translated_index() [1/2]

auto kblib::calculate_translated_index ( const char *  value,
const char *  p 
) -> std::ptrdiff_t
inline

Definition at line 588 of file convert.h.

◆ calculate_translated_index() [2/2]

template<typename string >
auto kblib::calculate_translated_index ( string &&  value,
const char *  p 
) -> std::ptrdiff_t

Definition at line 576 of file convert.h.

◆ call_each()

template<typename InputIt , typename EndIt , typename... Params>
constexpr auto kblib::call_each ( InputIt  first,
EndIt  last,
Params &&...  params 
) -> InputIt
constexprnoexcept

Definition at line 1588 of file algorithm.h.

◆ chooseCategorical()

template<typename Array , typename RandomGenerator , typename freqtype = double>
auto kblib::chooseCategorical ( Array &&  cats,
RandomGenerator &  r 
) -> decltype(cats.size())

Given a categorical distribution cats, selects one category.

Deprecated:
std::discrete_distribution provides the same functionality, with a worse name. Because it exists, there is no reason to use this function.
Parameters
catsA sequence of category weights
rA <random>-compatible RandomGenerator
Todo:
Refactor to remove the ugly unreachable stuff.

Definition at line 62 of file random.h.

◆ coerce()

template<typename To , typename... Ts>
auto kblib::coerce ( const std::variant< Ts... > &  v) -> To

Lexically converts the value of v (no matter its type) to type To.

Deprecated:
Use lexical_coerce instead, as it more clearly expresses intent.
Parameters
vA variant to coerce.
Returns
To The type to coerce to.

Definition at line 67 of file variant.h.

◆ construct_from_range()

template<typename Container , typename Range >
constexpr auto kblib::construct_from_range ( Range &&  r) -> Container
constexpr

Allows for constructing a container of a specified type from a range object. Copy elision means that this does not result in any extra copies.

Template Parameters
ContainerThe container type to construct an object of.
Parameters
rThe range to construct the returned container from.
Returns
Container Container{begin(r), end(r)};

Definition at line 152 of file containers.h.

◆ consumer()

template<typename F >
auto kblib::consumer ( f) -> consume_iterator<F>

Creates a consume_iterator of deduced type F.

This could be a deduction guide, if kblib didn't also support C++14. Thus, the old style is used for compatibility.

Parameters
fA functor to call on assignment.
Returns
consume_iterator<F>

Definition at line 1599 of file iterators.h.

◆ contains() [1/2]

template<typename Set , typename Value >
constexpr auto kblib::contains ( const Set &  set,
const Value &  val 
) -> enable_if_t<is_iterable<Set>::value, bool>
constexprnoexcept

Determine if a range contains a value.

Definition at line 1063 of file algorithm.h.

◆ contains() [2/2]

template<typename InputIt , typename Value >
constexpr auto kblib::contains ( InputIt  begin,
InputIt  end,
const Value &  val 
) -> enable_if_t<is_input_iterator<InputIt>::value, bool>
constexprnoexcept

Determine if a range contains a value.

Definition at line 1052 of file algorithm.h.

◆ contains_any() [1/3]

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>
constexpr

Definition at line 1087 of file algorithm.h.

◆ contains_any() [2/3]

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>
constexpr

Definition at line 1076 of file algorithm.h.

◆ contains_any() [3/3]

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>
constexpr

Definition at line 1098 of file algorithm.h.

◆ copy()

template<typename InputIt , typename EndIt , typename OutputIt >
constexpr auto kblib::copy ( InputIt  first,
EndIt  last,
OutputIt  out 
) -> OutputIt
constexpr

Copies all elements of [first, last) to out. It also allows for a sentinel end iterator.

Remarks
This function is constexpr in C++14.
Parameters
firstThe beginning of the input range
lastThe end of the input range
outThe beginning of the output range
Returns
OutputIt An iterator to past the last element written

Definition at line 1322 of file algorithm.h.

◆ copy_if()

template<typename InputIt , typename EndIt , typename OutputIt , typename UnaryPredicate >
constexpr auto kblib::copy_if ( InputIt  first,
EndIt  last,
OutputIt  out,
UnaryPredicate  pred 
) -> OutputIt
constexpr

Copies those elements of [first, last) which satisfy pred to out. It also allows for a sentinel end iterator.

Remarks
This function is constexpr in C++14.
Parameters
firstThe beginning of the input range
lastThe end of the input range
outThe beginning of the output range
predThe predicate to apply
Returns
OutputIt An iterator to past the last element written

Definition at line 1343 of file algorithm.h.

◆ copy_n()

template<typename InputIt , typename Size , typename OutputIt >
constexpr auto kblib::copy_n ( InputIt  first,
Size  count,
OutputIt  out 
) -> OutputIt
constexpr

Copies all elements of [first, std::advance(first, n)) to out.

Remarks
This function is constexpr in C++14.
Parameters
firstThe beginning of the input range.
countThe number of elements in the input range.
outThe output range.
Returns
OutputIt OutputIt An iterator to past the last element written

Definition at line 1365 of file algorithm.h.

◆ copy_n_if()

template<typename InputIt , typename Size , typename OutputIt , typename UnaryPredicate >
constexpr auto kblib::copy_n_if ( InputIt  first,
Size  count,
OutputIt  out,
UnaryPredicate  pred 
) -> OutputIt
constexpr

Copies those elements of [first, std::advance(first, n)) which satisfy pred to out.

Remarks
This function is constexpr in C++14.
Parameters
firstThe beginning of the input range.
countThe number of elements in the input range.
outThe output range.
predThe predicate to apply.
Returns
OutputIt OutputIt An iterator to past the last element written

Definition at line 1386 of file algorithm.h.

◆ count_digits() [1/2]

template<typename Number >
constexpr auto kblib::count_digits ( Number  val) -> enable_if_t<std::is_floating_point<Number>::value, int>
constexpr

Calculates the number of decimal digits needed to represent a number, plus one for negative numbers.

Calculates the number of decimal digits needed to represent a number.

Parameters
valThe number to be checked.
Returns
int The number of digits needed to represent a number.

Definition at line 50 of file format.h.

◆ count_digits() [2/2]

template<typename Number >
constexpr auto kblib::count_digits ( Number  val,
int  base 
) -> int
constexpr

Calculates the number of digits needed to represent a number in a given base, plus one for negative numbers.

Parameters
valThe number to be checked.
baseThe base to be used for calculation.
Returns
int The number of digits needed to represent a number.

Definition at line 107 of file format.h.

◆ counting_back_inserter()

template<typename C >
counting_back_insert_iterator<C> kblib::counting_back_inserter ( C &  c,
std::size_t  count = 0 
)

Definition at line 202 of file iterators.h.

◆ cry_enumerate() [1/2]

template<typename Iter1 , typename Iter2 >
auto kblib::cry_enumerate ( Iter1  begin,
Iter2  end 
) -> auto

Definition at line 1070 of file iterators.h.

◆ cry_enumerate() [2/2]

template<typename Range >
auto kblib::cry_enumerate ( Range &&  range) -> auto
Author
Krystian Stasiowski, killerbee
Date
2020

Definition at line 186 of file enumerate-contrib-cry.h.

◆ defer()

template<typename F >
auto kblib::defer ( f)

Definition at line 88 of file simple.h.

◆ div()

template<typename T , typename U >
constexpr auto kblib::div ( num,
den 
) -> decltype(std::div(num, den))
constexprnoexcept

Definition at line 48 of file stats.h.

◆ duration_to_str() [1/3]

template<typename Rep , typename Ratio , enable_if_t< detail_units::is_si_ratio< typename Ratio::type >::value > * = 0>
auto kblib::duration_to_str ( std::chrono::duration< Rep, Ratio > &  d) -> std::string

Definition at line 463 of file convert.h.

◆ duration_to_str() [2/3]

template<typename Rep >
auto kblib::duration_to_str ( std::chrono::duration< Rep, std::ratio< 3600 >>  d) -> std::string

Definition at line 489 of file convert.h.

◆ duration_to_str() [3/3]

template<typename Rep >
auto kblib::duration_to_str ( std::chrono::duration< Rep, std::ratio< 60 >>  d) -> std::string

Definition at line 484 of file convert.h.

◆ e()

template<typename T >
constexpr auto kblib::e ( ) -> T
constexpr

Definition at line 348 of file stats.h.

◆ eat_space()

std::istream& kblib::eat_space ( std::istream &  is)
inline

Eat spaces, don't eat an extra.

Deprecated:
Use std::ws instead.
Parameters
is
Returns
std::istream

Definition at line 173 of file io.h.

◆ eat_word()

auto kblib::eat_word ( std::istream &  is) -> std::istream&
inline

Consume all non-spaces to first break, then eat that, too.

Parameters
is
Returns
std::istream

Definition at line 158 of file io.h.

◆ ends_with() [1/2]

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>
constexpr

Checks if a given range ends with a particular subrange.

Definition at line 781 of file algorithm.h.

◆ ends_with() [2/2]

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>
constexpr

Checks if a given range ends with a particular subrange.

Definition at line 803 of file algorithm.h.

◆ enumerate() [1/2]

template<typename It , typename EIt >
constexpr auto kblib::enumerate ( It  begin,
EIt  end 
) -> enumerate_t<It, EIt>
constexpr

Allow access to indexes while using range-based for loops.

Parameters
begin,endThe input range.

Definition at line 168 of file enumerate-contrib-tw.h.

◆ enumerate() [2/2]

template<typename Range >
constexpr auto kblib::enumerate ( Range &&  r) -> enumerate_t<Range&&>
constexpr

Allow access to indexes while using range-based for loops. Safe to use with rvalues.

Parameters
rA range to iterate over.

Definition at line 158 of file enumerate-contrib-tw.h.

◆ equal() [1/6]

template<class InputIt1 , class InputIt2 >
constexpr auto kblib::equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2 
) -> bool
constexpr

Definition at line 959 of file fakestd.h.

◆ equal() [2/6]

template<typename InputIt1 , typename InputIt2 , typename BinaryPredicate , typename kblib::enable_if_t< not std::is_same< InputIt2, BinaryPredicate >::value, int > = 0>
constexpr auto kblib::equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
BinaryPredicate  p 
) -> bool
constexpr

Definition at line 972 of file fakestd.h.

◆ equal() [3/6]

template<class InputIt1 , class InputIt2 , typename kblib::enable_if_t< not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt1 >::iterator_category >::value or not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2 
) -> bool
constexpr

Definition at line 1037 of file fakestd.h.

◆ equal() [4/6]

template<typename InputIt1 , typename InputIt2 , typename BinaryPredicate , typename kblib::enable_if_t< not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt1 >::iterator_category >::value or not std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< InputIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
BinaryPredicate  p 
) -> bool
constexpr

Definition at line 1057 of file fakestd.h.

◆ equal() [5/6]

template<class RandomIt1 , class RandomIt2 , typename kblib::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt1 >::iterator_category >::value and std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal ( RandomIt1  first1,
RandomIt1  last1,
RandomIt2  first2,
RandomIt2  last2 
) -> bool
constexpr

Definition at line 991 of file fakestd.h.

◆ equal() [6/6]

template<class RandomIt1 , class RandomIt2 , typename BinaryPredicate , typename kblib::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt1 >::iterator_category >::value and std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< RandomIt2 >::iterator_category >::value, int > = 0>
constexpr auto kblib::equal ( RandomIt1  first1,
RandomIt1  last1,
RandomIt2  first2,
RandomIt2  last2,
BinaryPredicate  p 
) -> bool
constexpr

Definition at line 1014 of file fakestd.h.

◆ equals() [1/2]

template<typename Obj >
constexpr auto kblib::equals ( const Obj &  a,
const Obj &  b 
) -> bool
constexprnoexcept

Synthesize an equivalence relation from <.

Returns
bool Whether a is equivalent under < to b.

Definition at line 94 of file algorithm.h.

◆ equals() [2/2]

template<typename Obj , typename Compare >
constexpr auto kblib::equals ( const Obj &  a,
const Obj &  b,
Compare  comp 
) -> bool
constexprnoexcept

Synthesize an equivalence relation from comp.

Returns
bool Whether a is equivalent under comp to b.

Definition at line 106 of file algorithm.h.

◆ erase()

template<typename Container , typename Elem >
constexpr auto kblib::erase ( Container &  c,
const Elem &  val 
) -> void
constexprnoexcept

Abbreviation of the erase-remove idiom as a free function.

Parameters
cThe container to erase from.
valThe value to remove.

Definition at line 68 of file algorithm.h.

◆ erase_if()

template<typename Container , typename UnaryPredicate >
constexpr auto kblib::erase_if ( Container &  c,
UnaryPredicate  p 
) -> void
constexprnoexcept

Abbreviation of the erase-remove idiom as a free function.

Parameters
cThe container to erase from.
pErase all elements on which p returns true.

Definition at line 81 of file algorithm.h.

◆ escapify() [1/2]

auto kblib::escapify ( char  c) -> std::string
inline

Definition at line 545 of file convert.h.

◆ escapify() [2/2]

template<typename string >
auto kblib::escapify ( const string &  value) -> std::string

Definition at line 561 of file convert.h.

◆ etoi()

template<typename E , typename = typename std::enable_if<std::is_enum<E>::value>::type>
constexpr auto kblib::etoi ( e) -> auto
constexpr

Definition at line 241 of file convert.h.

◆ exchange()

template<typename T , typename U = T>
constexpr auto kblib::exchange ( T &  obj,
U &&  new_value 
) -> T
constexpr

Definition at line 718 of file fakestd.h.

◆ expect()

template<typename CharT >
auto kblib::expect ( CharT  c) -> auto

Read a character from an input stream only if it equals c. Acts as a FormattedInputOperation, that is, leading whitespace is ignored.

Definition at line 321 of file io.h.

◆ fibonacci()

template<typename U = std::uintmax_t>
constexpr auto kblib::fibonacci ( int  n) -> U
constexprnoexcept

Compile-time table fibonacci function.

Precondition
n <= calc_fib_size<U>()
Returns
The nth fibonacci number.

Definition at line 177 of file stats.h.

◆ filg2()

constexpr auto kblib::filg2 ( const std::bitset< std::numeric_limits< std::uintmax_t >::digits >  val) -> int
constexprnoexcept

Floored integer binary logarithm. Returns floor(lb(val)).

Returns the number of significant bits in the given integer.

Definition at line 146 of file simple.h.

◆ find() [1/2]

template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find ( ForwardIt  begin,
EndIt  end,
const Elem &  value 
) -> ForwardIt
constexprnoexcept

Finds a value in range [begin, end). If not found, returns end. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
valueThe value to search for
Returns
It Either the position of the found value, or end if not found

Definition at line 290 of file algorithm.h.

◆ find() [2/2]

template<typename ForwardIt , typename EndIt , typename Elem , typename Comp >
constexpr auto kblib::find ( ForwardIt  begin,
EndIt  end,
const Elem &  value,
Comp &&  comp 
) -> ForwardIt
constexprnoexcept

Finds a value in range [begin, end). If not found, returns end. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
valueThe value to search for
compThe comparison function
Returns
It Either the position of the found value, or end if not found

Definition at line 309 of file algorithm.h.

◆ find_if()

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_if ( ForwardIt  begin,
EndIt  end,
UnaryPredicate &&  pred 
) -> ForwardIt
constexprnoexcept

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.

Parameters
begin,endThe range to search in
predThe predicate to scan with
Returns
It Either the position of the found value, or end if not found

Definition at line 327 of file algorithm.h.

◆ find_if_not()

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_if_not ( ForwardIt  begin,
EndIt  end,
UnaryPredicate &&  pred 
) -> ForwardIt
constexprnoexcept

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.

Parameters
begin,endThe range to search in
predThe predicate to scan with
Returns
It Either the position of the found value, or end if not found

Definition at line 346 of file algorithm.h.

◆ find_in() [1/2]

template<typename Container , typename T >
constexpr auto kblib::find_in ( const Container &  c,
const T &  value 
) -> size_t
constexprnoexcept

Find the first element in c equal to v and return the position.

Equivalent to find_in(begin(c), end(c), v)

Parameters
cThe container to search.
valueThe value to search for.
Returns
size_t The position of the element found, or size(c) if not.

Definition at line 559 of file algorithm.h.

◆ find_in() [2/2]

template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find_in ( ForwardIt  begin,
EndIt  end,
const Elem &  value 
) -> size_t
constexprnoexcept

Find the offset of the first ocurrence of v in a range from the beginning. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
valueThe value to search for.
Returns
size_t The offset from begin of the first element equal to v, or distance(begin, end) if not found.

Definition at line 458 of file algorithm.h.

◆ find_in_if() [1/2]

template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_in_if ( const Container &  c,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept

Find the first element in c for which p returns true and return the position.

Equivalent to find_in_if(begin(c), end(c), p)

Parameters
cThe container to search in.
predThe predicate to check.
Returns
size_t The position of the element found, or size(c) if not.

Definition at line 585 of file algorithm.h.

◆ find_in_if() [2/2]

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_in_if ( ForwardIt  begin,
EndIt  end,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept

Find the offset of the first element for which p returns true. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
predThe predicate to check.
Returns
size_t The offset from begin of the element found, or distance(begin, end) if not.

Definition at line 474 of file algorithm.h.

◆ find_in_if_not() [1/2]

template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_in_if_not ( const Container &  c,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept

Find the first element in c for which p returns false and return the position.

Equivalent to find_in_if_not(begin(c), end(c), p)

Parameters
cThe container to search in.
predThe predicate to check.
Returns
size_t The position of the element found, or size(c) if not.

Definition at line 607 of file algorithm.h.

◆ find_in_if_not() [2/2]

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_in_if_not ( ForwardIt  begin,
EndIt  end,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept

Find the offset of the first element for which p returns false. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
predThe predicate to check.
Returns
size_t The offset from begin of the element found, or distance(begin, end) if not.

Definition at line 490 of file algorithm.h.

◆ find_last()

template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find_last ( ForwardIt  begin,
EndIt  end,
const Elem &  value 
) -> ForwardIt
constexprnoexcept

Searches a range for the last occurence of a match, and returns an iterator to it. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
valueThe value to find
Returns
It Iterator to the last element equal to v, or end if no such element.

Definition at line 366 of file algorithm.h.

◆ find_last_if()

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_if ( ForwardIt  begin,
EndIt  end,
UnaryPredicate  pred 
) -> ForwardIt
constexprnoexcept

Searches a range for the last element on which a predicate returns true. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
predThe predicate for comparison
Returns
It Iterator to the last element for which p returned true, or end if no such element.

Definition at line 396 of file algorithm.h.

◆ find_last_if_not()

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_if_not ( ForwardIt  begin,
EndIt  end,
UnaryPredicate  pred 
) -> ForwardIt
constexprnoexcept

Searches a range for the last element on which a predicate returns false. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
predThe predicate for comparison
Returns
It Iterator to the last element for which p returned false, or end if no such element.

Definition at line 427 of file algorithm.h.

◆ find_last_in() [1/2]

template<typename Container , typename T >
constexpr auto kblib::find_last_in ( const Container &  c,
const T &  value 
) -> size_t
constexprnoexcept

Find the last element in c equal to v and return the position.

Equivalent to find_last_in(std::begin(c), std::end(c), v)

Parameters
cThe container to search.
valueThe value to search for.
Returns
size_t The position of the element found, or c.size() if not.

Definition at line 645 of file algorithm.h.

◆ find_last_in() [2/2]

template<typename ForwardIt , typename EndIt , typename Elem >
constexpr auto kblib::find_last_in ( ForwardIt  begin,
EndIt  end,
const Elem &  value 
) -> size_t
constexprnoexcept

Find the offset of the last ocurrence of v in a range from the beginning. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
valueThe value to search for.
Returns
size_t The offset from begin of the element found, or distance(begin, end) if not.

Definition at line 510 of file algorithm.h.

◆ find_last_in_if() [1/2]

template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if ( const Container &  c,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept

Find the last element in c for which p returns true and return the position.

Equivalent to find_last_in_if(std::begin(c), std::end(c), p)

Parameters
cThe container to search in.
predThe predicate to check.
Returns
size_t The position of the element found, or c.size() if not.

Definition at line 664 of file algorithm.h.

◆ find_last_in_if() [2/2]

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if ( ForwardIt  begin,
EndIt  end,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept
Parameters
begin,endThe range to search in
begin,endThe range to search in
predThe predicate to check.
Returns
size_t The offset from begin of the element found, or distance(begin, end) if not.

Definition at line 525 of file algorithm.h.

◆ find_last_in_if_not() [1/2]

template<typename Container , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if_not ( const Container &  c,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept

Find the last element in c for which p returns true and return the position.

Equivalent to find_last_in_if_not(std::begin(c), std::end(c), p)

Parameters
cThe container to search in.
predThe predicate to check.
Returns
size_t The position of the element found, or c.size() if not.

Definition at line 686 of file algorithm.h.

◆ find_last_in_if_not() [2/2]

template<typename ForwardIt , typename EndIt , typename UnaryPredicate >
constexpr auto kblib::find_last_in_if_not ( ForwardIt  begin,
EndIt  end,
UnaryPredicate  pred 
) -> size_t
constexprnoexcept

Find the offset of the last element for which p returns false. It also allows for a sentinel end iterator.

Parameters
begin,endThe range to search in
predThe predicate to check.
Returns
size_t The offset from begin of the element found, or distance(begin, end) if not.

Definition at line 541 of file algorithm.h.

◆ find_match() [1/2]

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>>
constexpr

Definition at line 701 of file algorithm.h.

◆ find_match() [2/2]

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>>
constexpr

Definition at line 717 of file algorithm.h.

◆ first_result() [1/3]

template<typename InputIt , typename EndIt , typename T , typename UnaryTransform >
constexpr auto kblib::first_result ( InputIt  begin,
EndIt  end,
def,
UnaryTransform  op 
) -> enable_if_t<is_input_iterator<InputIt>::value, std::decay_t<decltype(op(*begin))>>
constexpr

Definition at line 821 of file algorithm.h.

◆ first_result() [2/3]

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,
def,
BinaryTransform  op 
) -> enable_if_t<is_input_iterator<InputIt1>::value and is_input_iterator<InputIt2>::value, std::decay_t<decltype(op(*begin1, *begin2))>>
constexpr

Definition at line 851 of file algorithm.h.

◆ first_result() [3/3]

template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename T , typename BinaryTransform >
constexpr auto kblib::first_result ( InputIt1  begin1,
EndIt1  end1,
InputIt2  begin2,
def,
BinaryTransform  op 
) -> enable_if_t<is_input_iterator<InputIt1>::value and is_input_iterator<InputIt2>::value, std::decay_t<decltype(op(*begin1, *begin2))>>
constexpr

Definition at line 835 of file algorithm.h.

◆ first_result_if() [1/3]

template<typename InputIt , typename EndIt , typename T , typename UnaryTransform , typename UnaryPredicate >
constexpr auto kblib::first_result_if ( InputIt  begin,
EndIt  end,
def,
UnaryTransform  op,
UnaryPredicate  ch 
) -> enable_if_t<is_input_iterator<InputIt>::value, decltype(op(*begin))>
constexpr

Definition at line 868 of file algorithm.h.

◆ first_result_if() [2/3]

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,
def,
BinaryTransform  op,
BinaryPredicate  ch 
) -> enable_if_t<is_input_iterator<InputIt1>::value and is_input_iterator<InputIt2>::value, decltype(op(*begin1, *begin2))>
constexpr

Definition at line 898 of file algorithm.h.

◆ first_result_if() [3/3]

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,
def,
BinaryTransform  op,
BinaryPredicate  ch 
) -> enable_if_t<is_input_iterator<InputIt1>::value and is_input_iterator<InputIt2>::value, decltype(op(*begin1, *begin2))>
constexpr

Definition at line 881 of file algorithm.h.

◆ first_result_opt() [1/3]

template<typename InputIt , typename EndIt , typename T , typename UnaryTransform >
constexpr auto kblib::first_result_opt ( InputIt  begin,
EndIt  end,
def,
UnaryTransform  op 
) -> enable_if_t<is_input_iterator<InputIt>::value, std::decay_t<decltype(op(*begin))>>
constexpr

Definition at line 920 of file algorithm.h.

◆ first_result_opt() [2/3]

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,
def,
BinaryTransform  op 
) -> enable_if_t<is_input_iterator<InputIt1>::value and is_input_iterator<InputIt2>::value, std::decay_t<decltype(op(*begin1, *begin2))>>
constexpr

Definition at line 950 of file algorithm.h.

◆ first_result_opt() [3/3]

template<typename InputIt1 , typename EndIt1 , typename InputIt2 , typename T , typename BinaryTransform >
constexpr auto kblib::first_result_opt ( InputIt1  begin1,
EndIt1  end1,
InputIt2  begin2,
def,
BinaryTransform  op 
) -> enable_if_t<is_input_iterator<InputIt1>::value and is_input_iterator<InputIt2>::value, std::decay_t<decltype(op(*begin1, *begin2))>>
constexpr

Definition at line 934 of file algorithm.h.

◆ flip() [1/2]

template<typename BinaryOperation >
constexpr auto kblib::flip ( ) -> auto
constexpr

Transforms a stateless binary operation into one which takes reversed arguments.

For example, kblib::flip<std::minus<>>() returns a function object which subtracts its first argument from its second.

Template Parameters
BinaryOperationThe operation to reverse.

Definition at line 102 of file simple.h.

◆ flip() [2/2]

template<typename BinaryOperation >
constexpr auto kblib::flip ( BinaryOperation  op) -> auto
constexpr

Transforms a binary operation into one which takes reversed arguments.

For example, kblib::flip(std::minus<>{}) returns a function object which subtracts its first argument from its second.

Parameters
opThe operation to reverse.

Definition at line 118 of file simple.h.

◆ FNV32a()

constexpr auto kblib::FNV32a ( std::string_view  s,
std::uint32_t  hval = fnv::fnv_offset<std::uint32_t>::value 
) -> std::uint32_t
constexprnoexcept

A standard FNV32a hash function, for string_views.

Parameters
sThe data to hash.
hvalThe initial value for the hash accumulator. Pass in another hash value to create a hash of the concatenation of the two ranges.
Returns
std::uint32_t The FNV32a hash of the input range.

Definition at line 194 of file hash.h.

◆ FNV32a_a()

template<std::size_t N>
constexpr auto kblib::FNV32a_a ( const char(&)  s[N],
std::uint32_t  hval = fnv::fnv_offset<std::uint32_t>::value 
) -> std::uint32_t
constexprnoexcept

A standard FNV32a hash function, for raw character arrays, such as string literals.

Parameters
sThe data to hash.
hvalThe initial value for the hash accumulator. Pass in another hash value to create a hash of the concatenation of the two ranges.
Returns
HashInt The FNV32a hash of the input range.

Definition at line 233 of file hash.h.

◆ FNV32a_s()

constexpr auto kblib::FNV32a_s ( const char *  begin,
std::size_t  length,
uint32_t  hval = fnv::fnv_offset<std::uint32_t>::value 
) -> std::uint32_t
constexprnoexcept

Definition at line 245 of file hash.h.

◆ FNVa()

template<typename HashInt , typename Span >
constexpr auto kblib::FNVa ( Span &&  s,
HashInt  hval = fnv::fnv_offset<HashInt>::value 
) -> HashInt
constexprnoexcept

A templatized generic FNVa hash function.

Template Parameters
HashIntThe unsigned integer type to use as the hash result. Must be either std::uint32_t or std::uint64_t.
Parameters
sThe data to hash. Any range-for-iterable span of char-like objects.
hvalThe initial value for the hash accumulator. Pass in another hash value to create a hash of the concatenation of the two ranges.
Returns
HashInt The FNVa hash of the input range.

Definition at line 147 of file hash.h.

◆ FNVa_a()

template<typename HashInt , typename CharT , std::size_t N>
constexpr auto kblib::FNVa_a ( const CharT(&)  s[N],
HashInt  hval = fnv::fnv_offset<HashInt>::value 
) -> HashInt
constexprnoexcept

A templatized FNVa hash function, for raw character arrays, such as string literals.

Template Parameters
HashIntThe unsigned integer type to use as the hash result. Must be either std::uint32_t or std::uint64_t.
Parameters
sThe data to hash. A raw array of char-like objects.
hvalThe initial value for the hash accumulator. Pass in another hash value to create a hash of the concatenation of the two ranges.
Returns
HashInt The FNVa hash of the input range.

Definition at line 173 of file hash.h.

◆ FNVa_s()

template<typename HashInt >
constexpr auto kblib::FNVa_s ( const char *  begin,
std::size_t  length,
HashInt  hval = fnv::fnv_offset<HashInt>::value 
) -> HashInt
constexprnoexcept

Definition at line 208 of file hash.h.

◆ for_each()

template<typename ForwardIt , typename EndIt , typename ForwardIt2 , typename BinaryFunction >
constexpr auto kblib::for_each ( ForwardIt  first,
EndIt  last,
ForwardIt2  second,
BinaryFunction  f 
) -> BinaryFunction
constexpr

Applies a binary operation to each pair of corresponding elements in two input ranges. It also allows for a sentinel end iterator.

In the style of <algorithm> algorithms, the second range is simply assumed to be at least as large as the first.

Parameters
firstThe beginning of the first input range.
lastThe end of the first input range.
secondThe beginning of the second input range.
fThe operation to apply.
Returns
BinaryFunction f

Definition at line 1280 of file algorithm.h.

◆ for_each_n()

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>
constexpr

Applies a binary operation to each pair of corresponding elements in two input ranges.

Parameters
firstThe beginning of the first input range.
nThe number of elements to operate on in each input range.
secondThe beginning of the second input range.
fThe operation to apply.
Returns
std::pair<ForwardIt, ForwardIt2> Equivalent to {std::advance(first, n), std::advance(second, n)}

Definition at line 1301 of file algorithm.h.

◆ force_shrink_to_fit()

template<typename V >
auto kblib::force_shrink_to_fit ( V &  vec) -> void

std::vector::shrink_to_fit is non-binding, which means that there is no guaranteed way to shrink a vector via its API. This function is a roundabout way of doing that without relying on the sanity of the implementation (except that it assumes that a vector won't significantly over-allocate on sized construction).

This function explicitly constructs a new vector and moves into it, before overwriting the old vector with the new one, meaning that the vector is forced to forget its capacity.

This function provides the strong exception guarantee.

Parameters
vecThe vector to force-shrink.

Definition at line 116 of file containers.h.

◆ fromStr() [1/5]

template<typename T >
auto kblib::fromStr ( const icu::UnicodeString &  val,
const char *  type = typeid(T).name() 
) -> T

Reencodes val to UTF-8 and then converts it to T using the primary overload.

Parameters
valA string holding data to convert.
typeA type name to be used in error messages.
Returns
T The converted value.

Definition at line 149 of file icu.h.

◆ fromStr() [2/5]

template<>
auto kblib::fromStr ( const std::string &  val,
const char *  type 
) -> std::string
inline

Definition at line 638 of file convert.h.

◆ fromStr() [3/5]

template<typename T >
auto kblib::fromStr ( const std::string &  val,
const char *  type = typeid(T).name() 
) -> T

Definition at line 627 of file convert.h.

◆ fromStr() [4/5]

template<>
auto kblib::fromStr ( std::string &&  val,
const char *  type 
) -> std::string
inline

Definition at line 666 of file convert.h.

◆ fromStr() [5/5]

template<typename T >
auto kblib::fromStr ( std::string &&  val,
const char *  type = typeid(T).name() 
) -> T

Definition at line 655 of file convert.h.

◆ fromUTF32()

template<typename string >
auto kblib::fromUTF32 ( string  s) -> icu::UnicodeString

Converts a UTF-32 string into a UnicodeString.

This functionality is present in ICU, and is only provided here for consistency with the above.

Parameters
sThe string to convert.
Returns
icu::UnicodeString The re-encoded result.

Definition at line 99 of file icu.h.

◆ fromUTF8()

template<typename string >
auto kblib::fromUTF8 ( string  s) -> icu::UnicodeString

Convert a UTF-8 string into a UnicodeString.

This functionality is present in ICU, and is only provided here for consistency with the above.

Parameters
sThe string to convert.
Returns
icu::UnicodeString The re-encoded result.

Definition at line 67 of file icu.h.

◆ generate()

template<typename OutputIt , typename EndIt , typename Generator >
constexpr auto kblib::generate ( OutputIt  first,
EndIt  last,
Generator  g 
) -> OutputIt
constexprnoexcept

Like std::generate except that it returns the output iterator at the end. It also allows for a sentinel end iterator.

Parameters
firstThe beginning of the ouput range.
lastThe end of the output range.
gA generator to repeatedly call and assign the return values to the elements of the output range.
Returns
ForwardIt The iterator pointing past the last element written.

Definition at line 1530 of file algorithm.h.

◆ generate_n()

template<typename OutputIt , typename Size , typename Generator >
constexpr auto kblib::generate_n ( OutputIt  first,
Size  count,
Generator  g 
) -> OutputIt
constexprnoexcept

Like std::generate_n except that it is constexpr.

Parameters
firstThe beginning of the ouput range.
countThe number of elements to generate.
gA generator to repeatedly call and assign the return values to the elements of the output range.
Returns
ForwardIt The iterator pointing past the last element written.

Definition at line 1550 of file algorithm.h.

◆ get() [1/8]

template<std::size_t I, typename T >
auto kblib::get ( const enumeration< T > &&  e) -> decltype(auto)

Definition at line 833 of file iterators.h.

◆ get() [2/8]

template<std::size_t I, typename... Types>
auto kblib::get ( const punner< Types... > &&  p) -> decltype(auto)
noexcept

Definition at line 739 of file bits.h.

◆ get() [3/8]

template<std::size_t I, typename... Types>
auto kblib::get ( const punner< Types... > &  p) -> decltype(auto)
noexcept

Definition at line 731 of file bits.h.

◆ get() [4/8]

template<std::size_t I, typename T >
auto kblib::get ( const volatile enumeration< T > &  e) -> decltype(auto)

Definition at line 854 of file iterators.h.

◆ get() [5/8]

template<std::size_t I, typename T >
auto kblib::get ( enumeration< T > &&  e) -> decltype(auto)

Definition at line 824 of file iterators.h.

◆ get() [6/8]

template<std::size_t I, typename... Types>
auto kblib::get ( punner< Types... > &&  p) -> decltype(auto)
noexcept

Definition at line 735 of file bits.h.

◆ get() [7/8]

template<std::size_t I, typename... Types>
auto kblib::get ( punner< Types... > &  p) -> decltype(auto)
noexcept

Definition at line 727 of file bits.h.

◆ get() [8/8]

template<std::size_t I, typename T >
auto kblib::get ( volatile enumeration< T > &  e) -> decltype(auto)

Definition at line 844 of file iterators.h.

◆ get_byte_index() [1/4]

template<typename T >
auto kblib::get_byte_index ( const std::unique_ptr< T > &  x,
std::size_t  idx 
) -> unsigned char
noexcept

Definition at line 317 of file sort.h.

◆ get_byte_index() [2/4]

template<typename T >
constexpr auto kblib::get_byte_index ( const T &  x,
std::size_t  idx 
) -> enable_if_t<std::is_enum<T>::value, unsigned char>
constexprnoexcept

Definition at line 304 of file sort.h.

◆ get_byte_index() [3/4]

template<typename T >
auto kblib::get_byte_index ( T *  x,
std::size_t  idx 
) -> unsigned char
noexcept

Definition at line 312 of file sort.h.

◆ get_byte_index() [4/4]

template<typename T >
constexpr auto kblib::get_byte_index ( x,
std::size_t  idx 
) -> enable_if_t<std::is_integral<T>::value, unsigned char>
constexprnoexcept

Definition at line 299 of file sort.h.

◆ get_check()

template<typename M , typename K >
constexpr auto kblib::get_check ( M &&  m,
const K &  key 
) -> exists_t<decltype(m.find(key))>
constexprnoexcept

Definition at line 94 of file containers.h.

◆ get_contents()

template<typename D = std::string, typename std::enable_if_t< is_contiguous_v< D >, int > = 0>
auto kblib::get_contents ( std::istream &  in,
D &  out 
) -> auto

Definition at line 64 of file io.h.

◆ get_file_contents()

template<typename D = std::string, typename string >
auto kblib::get_file_contents ( const string &  filename) -> std::optional<D>

Read the entire contents of a file into a container, such as std::string or std::vector<char>. Note that it will be most efficient to read into contiguous containers, as opposed to non-contiguous containers.

Parameters
filenameThe filename to open.
Template Parameters
DA contiguous sequence container, which will be created and filled with the contents of the file to be read.
Returns
std::optional<D> The contents of the file, if reading was successful.

Definition at line 97 of file io.h.

◆ get_line() [1/2]

template<typename CharT , typename... O, template< typename, typename... > class string>
auto kblib::get_line ( string< CharT, O... > &  str) -> auto
inline

Read a whole line into a std::basic_string-like class template.

When used like os >> get_line(str); for a std::ostream& os and std::string str, reads a full line into str instead of just a single word.

Parameters
strThe string to read a line into.

Definition at line 340 of file io.h.

◆ get_line() [2/2]

template<typename CharT , typename... O, template< typename, typename... > class string>
auto kblib::get_line ( string< CharT, O... > &  str,
CharT  delim 
) -> auto
inline

Read a delimited string into a std::basic_string-like class template.

When used like os >> get_line(str, '
'); for a std::ostream& os and std::string str, reads a full line into str instead of just a single word.

Parameters
strThe string to read into.
delimThe delimiter at which to stop reading text.

Definition at line 361 of file io.h.

◆ get_max_n() [1/2]

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>
constexpr

Copies the count greatest elements according to cmp of the range [first, last) to the range beginning at d_begin.

Note that this function uses O(count) extra memory to store a mutable range for sorting. Directly calling std::partial_sort_copy with a properly sized container will be more efficient than this function because it avoids allocating extra working memory. This function should rather be used for non-random-access output ranges.

Parameters
firstThe beginning of the range.
lastOne past the end of the range.
d_beginThe beginning of the output range.
countThe number of elements to copy out of the range.
cmpThe comparison function to use.
Returns
OutputIt An iterator to past the last element written.

Definition at line 1257 of file algorithm.h.

◆ get_max_n() [2/2]

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
constexpr

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.

Returns a container of the greatest count elements according to cmp of the range [first, last). This overload works for set-like containers.

Parameters
firstThe beginning of the range.
lastOne past the end of the range.
countThe number of elements to copy out of the range.
cmpThe comparison function to use.
Returns
SequenceContainer The greatest count elements of the range, in arbitrary order.
Parameters
firstThe beginning of the range.
lastOne past the end of the range.
countThe number of elements to copy out of the range.
cmpThe comparison function to use.
Returns
SetlikeContainer The greatest count elements of the range, in arbitrary order.

Definition at line 1203 of file algorithm.h.

◆ get_max_n_old()

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
constexpr

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.

Returns a container of the greatest count elements according to cmp of the range [first, last). This overload works for set-like types.

This function is included because its performance is sometimes better than the new version, and additionally, it does not rely on default-constructibility for the value type.

Attention
The returned container will not be sorted, unless it is something like std::multiset which will use the other overload.
Parameters
firstThe beginning of the range.
lastOne past the end of the range.
countThe number of elements to copy out of the range.
cmpThe comparison function to use.
Returns
SequenceContainer The greatest count elements of the range, in arbitrary order.

This function is included because its performance is sometimes better than the new version, and additionally, it does not rely on default-constructibility for the value type.

Parameters
firstThe beginning of the range.
firstOne past the end of the range.
countThe number of elements to copy out of the range.
cmpThe comparison function to use.
Returns
SetlikeContainer The greatest count elements of the range, in arbitrary order.

Definition at line 1146 of file algorithm.h.

◆ get_or()

template<class C , typename K , typename V >
constexpr auto kblib::get_or ( const C &  m,
const K &  key,
const V &  defval 
) -> typename C::mapped_type
constexpr

Definition at line 57 of file containers.h.

◆ getline()

auto kblib::getline ( std::istream &  is) -> std::string
inline

By-value std::getline wrapper.

Parameters
isThe stream to extract from.
Returns
std::string A single line of text from the stream.

Definition at line 146 of file io.h.

◆ html_encode()

template<typename string >
auto kblib::html_encode ( const string &  data) -> std::string

Definition at line 516 of file convert.h.

◆ indirect()

template<typename Iter1 , typename Iter2 >
constexpr auto kblib::indirect ( Iter1  begin,
Iter2  end 
) -> indirect_range<Iter1, Iter2>
constexprnoexcept

Create a range from an iterator pair. Primarily useful for range-for loops.

Parameters
begin,endThe range to wrap.

Definition at line 1059 of file iterators.h.

◆ indirect_range()

template<typename Iter1 , typename Iter2 >
kblib::indirect_range ( Iter1  ,
Iter2   
) -> indirect_range< Iter1, Iter2 >

◆ insertion_sort()

template<typename RandomAccessIt , typename Compare = std::less<>>
constexpr auto kblib::insertion_sort ( const RandomAccessIt  begin,
const RandomAccessIt  end,
Compare &&  compare = {} 
) -> void
constexprnoexcept

In-place insertion sort. As is usual, it is stable. Provides as a guarantee that it will perform no moves on sorted input.

Remarks
Complexity:
Average case O(n^2)
Best-case Θ(n) (for sorted input)
worst-case O(n^2) (for reverse-sorted input)
Parameters
begin,endThe range to sort
compareThe comparison predicate

Definition at line 57 of file sort.h.

◆ insertion_sort_copy()

template<typename RandomAccessIt , typename RandomAccessIt2 , typename Compare = std::less<>>
constexpr auto kblib::insertion_sort_copy ( const RandomAccessIt  begin,
const RandomAccessIt  end,
const RandomAccessIt2  d_begin,
const RandomAccessIt2  d_end,
Compare &&  compare = {} 
) -> void
constexprnoexcept

Out-of-place insertion sort, which does not modify the input. Provides as a guarantee that it will perform no moves on sorted input.

Remarks
Complexity:
Average case O(n^2)
Best-case Θ(n) (for sorted input)
worst-case O(n^2) (for reverse-sorted input)
Parameters
begin,endThe input range
d_begin,d_endThe output range
compareThe comparison predicate

Definition at line 93 of file sort.h.

◆ invoke()

template<typename F , typename... Args>
constexpr auto kblib::invoke ( F &&  f,
Args &&...  args 
) -> decltype(auto)
constexprnoexcept

Definition at line 130 of file fakestd.h.

◆ iota() [1/2]

template<typename ForwardIt , typename T >
constexpr auto kblib::iota ( ForwardIt  first,
ForwardIt  last,
value 
) -> void
constexprnoexcept

Definition at line 1560 of file algorithm.h.

◆ iota() [2/2]

template<typename ForwardIt , typename T , typename UnaryOperation >
constexpr auto kblib::iota ( ForwardIt  first,
ForwardIt  last,
value,
UnaryOperation  unary_op 
) -> void
constexprnoexcept

Definition at line 1572 of file algorithm.h.

◆ ipow2()

template<typename UIntType >
constexpr auto kblib::ipow2 ( UIntType  b) -> UIntType
constexprnoexcept

Definition at line 280 of file random.h.

◆ irange()

template<typename Value , typename Delta = int>
constexpr auto kblib::irange ( Value  ,
Value  ,
Delta  = 0 
)
constexpr

Definition at line 659 of file iterators.h.

◆ is_consecutive()

template<typename T , std::size_t N>
constexpr auto kblib::is_consecutive ( const T(&)  array[N]) -> enable_if_t<std::is_integral<T>::value, bool>
constexpr

Definition at line 125 of file simple.h.

◆ kbsplit2()

template<typename Container = std::vector<std::string>, typename String >
auto kblib::kbsplit2 ( const String &  in,
char  delim = ' ' 
) -> Container

Definition at line 474 of file stringops.h.

◆ lexical_cast()

template<typename To , typename From >
auto kblib::lexical_cast ( const From &  val,
const char *  type = typeid(To).name() 
) -> To

Definition at line 833 of file convert.h.

◆ lexical_coerce()

template<typename To , typename... Ts>
auto kblib::lexical_coerce ( const std::variant< Ts... > &  v) -> To

Lexically converts the value of v (no matter its type) to type To.

Parameters
vA variant to coerce.
Returns
To The type to coerce to.

Definition at line 91 of file variant.h.

◆ lexicographical_compare()

template<class InputIt1 , class InputIt2 >
constexpr auto kblib::lexicographical_compare ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2 
) -> bool
constexpr

Definition at line 1079 of file fakestd.h.

◆ magic_enumerate() [1/2]

template<typename It , typename EIt >
auto kblib::magic_enumerate ( It  begin,
EIt  end 
) -> enumerator_t<It, EIt>

Allow access to indexes while using range-based for loops.

The "magic" part is that

for (auto&& [idx, val] : kblib::magic_enumerate(range)) {
auto magic_enumerate(It begin, EIt end) -> enumerator_t< It, EIt >
Allow access to indexes while using range-based for loops.
Definition: iterators.h:988
constexpr auto range(Value min, Value max, Delta step=0) -> range_t< Value, Delta >
Constructs a range from beginning, end, and step amount. The range is half-open, that is min is in th...
Definition: iterators.h:620

captures 'val' by reference, while

for (auto [idx, val] : kblib::magic_enumerate(range)) {

captures 'val' by value, so that the effect is similar to if you had written

for (auto val : range) {

and kept track of the index manually.

Parameters
begin,endThe input range.

Definition at line 988 of file iterators.h.

◆ magic_enumerate() [2/2]

template<typename Range >
auto kblib::magic_enumerate ( Range &&  r) -> auto

Allow access to indexes while using range-based for loops. Safe to use with rvalues.

The "magic" part is that

for (auto&& [idx, val] : kblib::magic_enumerate(range)) {

captures 'val' by reference, while

for (auto [idx, val] : kblib::magic_enumerate(range)) {

captures 'val' by value, so that the effect is similar to if you had written

for (auto val : range) {

and kept track of the index manually.

Parameters
rA range to iterate over.

Definition at line 1013 of file iterators.h.

◆ make_cond_ptr() [1/4]

template<typename T , typename Deleter >
auto kblib::make_cond_ptr ( std::unique_ptr< T, Deleter > &&  arg) -> cond_ptr<T, Deleter>
noexcept

Definition at line 780 of file memory.h.

◆ make_cond_ptr() [2/4]

template<typename T , typename Deleter >
auto kblib::make_cond_ptr ( T *  arg,
bool  owner,
Deleter  del 
) -> cond_ptr<T, Deleter>
noexcept

Definition at line 798 of file memory.h.

◆ make_cond_ptr() [3/4]

template<typename T >
auto kblib::make_cond_ptr ( T *  arg,
bool  owner = false 
) -> cond_ptr<T>
noexcept

Definition at line 786 of file memory.h.

◆ make_cond_ptr() [4/4]

template<typename T , typename Deleter >
auto kblib::make_cond_ptr ( T *  arg,
Deleter  del 
) -> cond_ptr<T, Deleter>
noexcept

Definition at line 792 of file memory.h.

◆ make_fib_arr()

template<typename U , std::size_t N = calc_fib_size<U>() + 1>
constexpr auto kblib::make_fib_arr ( ) -> trivial_array<U, N>
constexprnoexcept

Generates the first N values of the fibonacci sequence.

Precondition
If N > calc_fib_size<U>(), then U must be an unsigned type, and the resulting sequence is modulo 2^bits_of_U.
N >= 2
Returns
trivial_array<U, N> An array containing the first N fibonacci numbers.

Definition at line 156 of file stats.h.

◆ make_transform_iterator()

template<typename base_iterator , typename operation >
auto kblib::make_transform_iterator ( base_iterator  it,
operation  op 
) -> transform_iterator<base_iterator, operation>
noexcept

Factory function to make transform_iterators.

Parameters
itAn InputIterator to a range to transform.
opThe transformation to apply.
Returns
transform_iterator<base_iterator, operation>
Deprecated:
Use transformer instead

Definition at line 1291 of file iterators.h.

◆ map()

template<typename F , typename... T>
auto kblib::map ( f,
T &&...  t 
) -> enable_if_t< not any_void<decltype(kblib::apply(f, std::forward<T>(t)))...>, decltype(std::tuple{kblib::apply(f, std::forward<T>(t))...})>
noexcept

Definition at line 57 of file simple.h.

◆ max_count_digits() [1/2]

template<typename ForwardIt >
auto kblib::max_count_digits ( ForwardIt  first,
ForwardIt  last 
) -> int

Returns the necessary number of digits to represent the largest value in an input range.

Parameters
firstThe beginning of the input range.
lastThe end of the input range.
Returns
int The necessary number of digits to represent any value in the input.

Definition at line 130 of file format.h.

◆ max_count_digits() [2/2]

template<typename ForwardIt >
auto kblib::max_count_digits ( ForwardIt  first,
ForwardIt  last,
int  base 
) -> int

Returns the necessary number of digits to represent the largest value in an input range.

Parameters
firstThe beginning of the input range.
lastThe end of the input range.
baseThe base to be used for calculation.
Returns
int The necessary number of digits to represent any value in the input.

Definition at line 148 of file format.h.

◆ max_element() [1/2]

template<typename Container , typename Comp = std::less<value_type_linear_t<Container>>>
auto kblib::max_element ( Container &  c,
Comp  comp 
) -> value_type_linear_t<Container>*

Definition at line 77 of file iterators.h.

◆ max_element() [2/2]

template<typename ForwardIt , typename EndIt , typename Compare = std::less<>>
constexpr auto kblib::max_element ( ForwardIt  first,
EndIt  last,
Compare  comp = {} 
) -> ForwardIt
constexpr

Definition at line 1109 of file algorithm.h.

◆ memswap() [1/2]

constexpr auto kblib::memswap ( unsigned char *  A,
unsigned char *  B,
std::size_t  size 
) -> void
inlineconstexprnoexcept

Swaps memory ranges.

Precondition
A and B must not be null.
*A and *B must not overlap.
Parameters
AA pointer to memory to swap with *B.
BA pointer to memory to swap with *A.
sizeThe number of bytes to swap between *A and *B.

Definition at line 394 of file bits.h.

◆ memswap() [2/2]

auto kblib::memswap ( void *  A,
void *  B,
std::size_t  size 
) -> void
inlinenoexcept

Swaps memory ranges.

Precondition
A and B must not be null.
*A and *B must not overlap.
Parameters
AA pointer to memory to swap with *B.
BA pointer to memory to swap with *A.
sizeThe number of bytes to swap between *A and *B.

Definition at line 412 of file bits.h.

◆ nl()

template<typename CharT , typename Traits >
auto kblib::nl ( std::basic_istream< CharT, Traits > &  is) -> std::basic_istream<CharT, Traits>&

Read in spaces until the end of the line is found.

nl may be used to consume whitespace left over after a formatted input operation before doing an unformatted input operation (such as std::getline).

Remarks
Example usage:
int x{};
std::cout << "Enter a number: ";
std::cin >> x; // potentially leaves a new line in the stream
std::cout << "Got " << x << '\n';
std::string str;
std::cout << "Enter a line of text: ";
std::getline(std::cin >> kblib::nl, str);
std::cout << "Got " << std::quoted(str) << '\n';
auto nl(std::basic_istream< CharT, Traits > &is) -> std::basic_istream< CharT, Traits > &
Read in spaces until the end of the line is found.
Definition: io.h:212
auto quoted(string &&in) -> std::string
Definition: convert.h:606
auto getline(std::istream &is) -> std::string
By-value std::getline wrapper.
Definition: io.h:146
Parameters
isThe stream to read from.
Returns
std::istream& is.

Definition at line 212 of file io.h.

◆ none_of() [1/2]

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>
constexpr

Determine if pred is false for every element of the range.

Definition at line 997 of file algorithm.h.

◆ none_of() [2/2]

template<typename Range , typename UnaryPredicate >
constexpr auto kblib::none_of ( Range &&  rng,
UnaryPredicate  pred 
) -> enable_if_t<is_iterable<Range>::value, bool>
constexpr

Determine if pred is true for every element of the range.

Definition at line 1011 of file algorithm.h.

◆ noop() [1/2]

template<typename T >
auto kblib::noop ( void *  ,
const T *   
) -> T*
inline

Does nothing; matches the copy construction signature.

Definition at line 247 of file poly_obj.h.

◆ noop() [2/2]

template<typename T , bool nothrow>
auto kblib::noop ( void *  ,
T *   
) -> T*
inlinenoexcept

Does nothing; matches the move construction signature.

Definition at line 252 of file poly_obj.h.

◆ operator&()

constexpr auto kblib::operator& ( construct_type  l,
construct_type  r 
) -> construct_type
constexprnoexcept

Definition at line 54 of file poly_obj.h.

◆ operator*()

constexpr auto kblib::operator* ( construct_type  l,
bool  r 
) -> construct_type
constexprnoexcept

Definition at line 60 of file poly_obj.h.

◆ operator+() [1/3]

template<typename T >
constexpr auto kblib::operator+ ( val,
adjuster  a 
) -> enable_if_t<not detail_iterators::is_addable<T, std::ptrdiff_t>::value, decltype(std::advance(val, a.adj))>
constexprnoexcept

Definition at line 552 of file iterators.h.

◆ operator+() [2/3]

template<typename T >
constexpr auto kblib::operator+ ( val,
decrementer   
) -> T
constexpr

Decrements val.

Definition at line 605 of file iterators.h.

◆ operator+() [3/3]

template<typename T >
constexpr auto kblib::operator+ ( val,
incrementer   
) -> T
constexpr

Increments val.

Definition at line 580 of file iterators.h.

◆ operator<<()

template<typename F , typename CharT , typename Tr >
std::basic_ostream<CharT, Tr>& kblib::operator<< ( std::basic_ostream< CharT, Tr > &  is,
get_manip< F >  func 
)

Actually calls the manipulator.

Definition at line 373 of file io.h.

◆ operator>>()

template<typename F , typename CharT , typename Tr >
std::basic_istream<CharT, Tr>& kblib::operator>> ( std::basic_istream< CharT, Tr > &  is,
get_manip< F >  func 
)

Actually calls the manipulator.

Definition at line 373 of file io.h.

◆ operator|()

constexpr auto kblib::operator| ( construct_type  l,
construct_type  r 
) -> construct_type
constexprnoexcept

Definition at line 48 of file poly_obj.h.

◆ parse_integer() [1/3]

template<typename Result >
constexpr auto kblib::parse_integer ( const char *  begin,
const char *  end,
int  base = 0 
) -> Result
constexpr

Definition at line 148 of file convert.h.

◆ parse_integer() [2/3]

template<typename Result , std::size_t N>
constexpr auto kblib::parse_integer ( const char(&)  in[N],
int  base = 0 
) -> Result
constexpr

Definition at line 194 of file convert.h.

◆ parse_integer() [3/3]

template<typename Result >
constexpr auto kblib::parse_integer ( const std::string &  in,
int  base = 0 
) -> Result
constexpr

Definition at line 202 of file convert.h.

◆ phi()

template<typename T >
constexpr auto kblib::phi ( ) -> T
constexpr

Definition at line 356 of file stats.h.

◆ pi()

template<typename T >
constexpr auto kblib::pi ( ) -> T
constexpr

Definition at line 340 of file stats.h.

◆ poly_warn_if()

template<bool warn>
constexpr auto kblib::poly_warn_if ( ) -> std::nullptr_t
constexpr

Definition at line 1081 of file poly_obj.h.

◆ poly_warn_if< true >()

template<>
constexpr auto kblib::poly_warn_if< true > ( ) -> std::nullptr_t
inlineconstexpr

Definition at line 1088 of file poly_obj.h.

◆ pop()

template<typename C >
constexpr auto kblib::pop ( C &  s) -> typename C::value_type
constexpr

Definition at line 50 of file containers.h.

◆ quantize_range()

template<typename T , typename F >
constexpr auto kblib::quantize_range ( low,
high,
val 
) -> T
constexprnoexcept

Quantize a real-valued value into a discrete integer.

Template Parameters
TAn unsigned integral type.
Parameters
minThe real value corresponding to min in the output.
maxThe real value corresponding to max in the output.
valThe input value.
Returns
The quantized value of the input.

Definition at line 433 of file stats.h.

◆ quantize_step()

template<typename T , typename F >
constexpr auto kblib::quantize_step ( low,
delta,
val 
) -> T
constexprnoexcept

Quantize a real-valued value into a discrete integer.

TODO(killerbee13): write tests and fix style issues for quantization functions

Template Parameters
TAn unsigned integral type.
Parameters
minThe real value corresponding to 0 in the output.
deltaThe difference between quantization steps.
valThe input value.
Returns
The quantized value of the input.

Definition at line 417 of file stats.h.

◆ quoted()

template<typename string >
auto kblib::quoted ( string &&  in) -> std::string

Definition at line 606 of file convert.h.

◆ range() [1/2]

template<typename Value >
constexpr auto kblib::range ( Value  max) -> range_t<Value, incrementer>
constexpr

Constructs a half-open range [0, max). The step is automatically determined based on the sign of max.

Parameters
maxThe first value not in the produced range.
Returns
range_t<Value, int> An iterable range [0, max).

Definition at line 641 of file iterators.h.

◆ range() [2/2]

template<typename Value , typename Delta = int>
constexpr auto kblib::range ( Value  min,
Value  max,
Delta  step = 0 
) -> range_t<Value, Delta>
constexpr

Constructs a range from beginning, end, and step amount. The range is half-open, that is min is in the range but max is not. If unspecified, the step is automatically either 1 or -1, depending on whether max > min.

Parameters
minThe first value in the produced range.
maxThe first value not in the produced range.
stepThe difference between values in the produced range.
Returns
range_t<Value, Delta> An iterable range [min, max).

Definition at line 620 of file iterators.h.

◆ remove_null_terminator()

template<int N, typename Indices = std::make_integer_sequence<int, N - 1>>
constexpr auto kblib::remove_null_terminator ( const char(&)  arr[N]) -> std::array<char, N - 1>
constexpr

Creates an array of only the meaningful characters in a string literal, and not the null terminator.

Parameters
arrA string literal to strip the null terminator from.
Returns
std::array<char, N - 1> A std::array of the meaningful characters of the string literal.

Definition at line 135 of file traits.h.

◆ repeat() [1/3]

auto kblib::repeat ( char  val,
std::size_t  count 
) -> std::string
inline

Construct a string consisting of count copies of val.

This function is a trivial wrapper around a constructor of std::string provided for symmetry with the above overload.

Parameters
valThe character to be repeated.
countThe number of times to repeat val.

Definition at line 639 of file stringops.h.

◆ repeat() [2/3]

template<typename Callable >
constexpr auto kblib::repeat ( std::size_t  N,
Callable  func 
) -> return_assert_t<is_invocable<Callable>::value, void>
constexprnoexcept

Invoke a function N times.

Parameters
NThe number of times to invoke func.
funcThe function to invoke.

Definition at line 53 of file algorithm.h.

◆ repeat() [3/3]

template<typename string >
auto kblib::repeat ( string  val,
std::size_t  count 
) -> string

Construct a string consisting of count copies of val concatenated together.

This function currently works greedily and will be inefficient for large values of count.

Parameters
val
count
Todo:
Defer constrution of a string with a class.

Definition at line 622 of file stringops.h.

◆ replace_copy_if()

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
constexpr

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.

Remarks
This function is constexpr in C++14.
Parameters
firstThe beginning of the input range.
lastThe end of the input range.
outThe beginning of the output range.
predThe predicate to apply.
new_valueThe value to replace those elements for which pred is true with.
Returns
An iterator to past the last element written.

Definition at line 1413 of file algorithm.h.

◆ replace_copy_n_if()

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
constexpr

Copies an input range, but every element for which pred is true is replaced by new_value.

Remarks
This function is constexpr in C++14.
Parameters
firstThe beginning of the input range.
countThe number of elements to copy.
outThe beginning of the output range.
predThe predicate to apply.
new_valueThe value to replace those elements for which pred is true with.
Returns
OutputIt An iterator to past the last element written.

Definition at line 1444 of file algorithm.h.

◆ reverse_str()

template<typename string >
auto kblib::reverse_str ( string  val) -> string

Reverses all the elements of its input.

Attention
This function will not behave correctly with multibyte character encodings.
Parameters
valThe string to reverse.
Returns
string The reversed range.

Definition at line 552 of file stringops.h.

◆ root_2()

template<typename T >
constexpr auto kblib::root_2 ( ) -> T
constexpr

Definition at line 352 of file stats.h.

◆ rotate()

template<class ForwardIt >
constexpr auto kblib::rotate ( ForwardIt  first,
ForwardIt  n_first,
ForwardIt  last 
) -> ForwardIt
constexprnoexcept

Rotates the input range. This is just a constexpr-in-C++14 version of std::rotate.

Parameters
first
n_first
last
Returns
ForwardIt

Definition at line 1494 of file algorithm.h.

◆ safe_auto() [1/2]

template<typename T >
auto kblib::safe_auto ( T &&  in) -> T

Safely propagate an xvalue or lvalue without dangling references.

Definition at line 197 of file simple.h.

◆ safe_auto() [2/2]

template<typename T >
auto kblib::safe_auto ( T &  in) -> T&

Safely propagate an xvalue or lvalue without dangling references.

Definition at line 205 of file simple.h.

◆ saturating_cast()

template<typename A , typename F >
constexpr auto kblib::saturating_cast ( x) -> enable_if_t<std::is_integral<A>::value and std::is_integral<F>::value and std::is_unsigned<A>::value, A>
constexprnoexcept

Definition at line 362 of file stats.h.

◆ scoped_file()

template<typename File = std::fstream>
auto kblib::scoped_file ( const std::filesystem::path &  path,
std::ios_base::openmode  mode = std::ios_base::in | std::ios_base::out 
)

Definition at line 582 of file io.h.

◆ search_replace_copy()

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
constexpr

Definition at line 1461 of file algorithm.h.

◆ seeded() [1/2]

template<typename Gen >
auto kblib::seeded ( ) -> Gen

Definition at line 174 of file random.h.

◆ seeded() [2/2]

template<typename Gen , typename Source >
auto kblib::seeded ( Source &&  s) -> Gen

Definition at line 168 of file random.h.

◆ signed_cast()

template<typename A , typename F >
constexpr auto kblib::signed_cast ( x) -> enable_if_t<std::is_integral<A>::value and std::is_integral<F>::value and std::is_signed<A>::value, std::make_signed_t<F>>
constexpr

Cast argument to equivalently-sized type with the same signednessas the template parameter.

Definition at line 601 of file fakestd.h.

◆ signed_promote()

template<typename N >
constexpr auto kblib::signed_promote ( x) -> safe_signed_t<N>
constexprnoexcept

Definition at line 849 of file fakestd.h.

◆ size() [1/2]

template<typename C >
constexpr auto kblib::size ( const C &  c) -> decltype(c.size())
constexpr

Definition at line 1069 of file fakestd.h.

◆ size() [2/2]

template<typename T , std::size_t N>
constexpr auto kblib::size ( const   T(&)[N]) -> std::size_t
constexprnoexcept

Definition at line 1074 of file fakestd.h.

◆ sort() [1/2]

template<typename RandomAccessIt >
constexpr auto kblib::sort ( RandomAccessIt  begin,
RandomAccessIt  end 
) -> void
constexpr
Parameters
begin,endThe range to sort

Definition at line 731 of file sort.h.

◆ sort() [2/2]

template<typename RandomAccessIt , typename BinaryPredicate >
constexpr auto kblib::sort ( RandomAccessIt  begin,
RandomAccessIt  end,
BinaryPredicate &&  compare 
) -> void
constexpr

Sorts a range.

Complexity: worst-case O(N log(N)), where N = std::distance(begin, end) comparisons and swaps.

Parameters
begin,endThe range to sort
compareA comparison predicate which returns true if the first argument shall be ordered before the second. BinaryPredicate must meet the requirements of the Compare named requirement.

Definition at line 715 of file sort.h.

◆ sort_transform() [1/2]

template<typename RandomAccessIt , typename UnaryOperation >
constexpr auto kblib::sort_transform ( RandomAccessIt  begin,
RandomAccessIt  end,
UnaryOperation &&  transform 
) -> void
constexpr
Parameters
begin,endThe range to sort
transformThe transformation to apply

Definition at line 691 of file sort.h.

◆ sort_transform() [2/2]

template<typename RandomAccessIt , typename UnaryOperation , typename BinaryPredicate >
constexpr auto kblib::sort_transform ( RandomAccessIt  begin,
RandomAccessIt  end,
UnaryOperation &&  transform,
BinaryPredicate &&  compare 
) -> void
constexpr

Sorts a range after applying a transformation.

Complexity: worst-case O(N log(N)), where N = std::distance(begin, end) comparisons and swaps.

Parameters
begin,endThe range to sort
transformA transformer (such as unary function or pointer to member) which will be applied to each object before comparing it. A transformer may not modify the object it is called with.
compareA comparison predicate which returns true if the first argument shall be ordered before the second. BinaryPredicate must meet the requirements of the Compare named requirement.

Definition at line 674 of file sort.h.

◆ split_dsv() [1/2]

template<typename Container = std::vector<std::string>, typename String >
auto kblib::split_dsv ( const String &  str,
char  delim 
) -> Container

Split a string on all instances of delim.

Parameters
inThe string to split
delimThe character to split on.
Returns
Container A sequence container of all substrings in the split input.

Definition at line 501 of file stringops.h.

◆ split_dsv() [2/2]

template<typename Container = std::vector<std::string>, typename String , typename Predicate >
auto kblib::split_dsv ( const String &  str,
Predicate  delim 
) -> return_assert_t< is_callable<Predicate, typename Container::value_type::value_type>::value, Container>

Split a string on all instances of delim.

Parameters
inThe string to split
delimA predicate for delimiters.
Returns
Container A sequence container of all substrings in the split input.

Definition at line 522 of file stringops.h.

◆ split_tokens() [1/3]

template<typename Container = std::vector<std::string>, typename String >
auto kblib::split_tokens ( const String &  in) -> Container

Split a string on all instances of whitespace.

Parameters
inThe string to split
Returns
Container A sequence container of all substrings in the split input.

Definition at line 433 of file stringops.h.

◆ split_tokens() [2/3]

template<typename Container = std::vector<std::string>, typename Predicate , typename String >
auto kblib::split_tokens ( const String &  in,
Predicate  spacer 
) -> return_assert_t< is_callable<Predicate, typename Container::value_type::value_type>::value, Container>

Split a string on all condensed delimiters.

Parameters
inThe string to split
spacerA predicate which determines whether a character is a delimiter.
Returns
Container A sequence container of all substrings in the split input.

Definition at line 397 of file stringops.h.

◆ split_tokens() [3/3]

template<typename Container = std::vector<std::string>, typename String >
auto kblib::split_tokens ( const String &  in,
typename Container::value_type::value_type  delim 
) -> Container

Split a string on all instances of a delimiter.

Parameters
inThe string to split
delimThe character to split on. A run of delimiters is condensed.
Returns
Container A sequence container of all substrings in the split input.

Definition at line 445 of file stringops.h.

◆ starts_with() [1/2]

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>
constexpr

Checks if a given range starts with a particular subrange.

Definition at line 738 of file algorithm.h.

◆ starts_with() [2/2]

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>
constexpr

Checks if a given range ends with a particular subrange.

Definition at line 759 of file algorithm.h.

◆ static_coerce()

template<typename To , typename... Ts>
auto kblib::static_coerce ( const std::variant< Ts... > &  v) -> To

static_casts the value of v (no matter its type) to type To.

Parameters
vA variant to coerce.
Returns
To The type to coerce to.

Definition at line 80 of file variant.h.

◆ sum() [1/3]

template<typename InputIt >
constexpr auto kblib::sum ( InputIt  first,
InputIt  last 
) -> std::decay_t<decltype(*first)>
constexpr

Sum a range.

Convenience wrapper for std::accumulate. For an empty range, returns a value-initialized temporary (usually 0). Deduces the correct type for the initializer, which reduces risk of truncation and incorrect results.

Parameters
[in]firstBeginning of range
[in]lastEnd of range
Returns
The sum of the input range.

Definition at line 194 of file algorithm.h.

◆ sum() [2/3]

template<typename InputIt , typename BinaryOperation >
constexpr auto kblib::sum ( InputIt  first,
InputIt  last,
BinaryOperation  op 
) -> std::decay_t<decltype(*first)>
constexpr

Fold a range over an operation.

Convenience wrapper for std::accumulate. For an empty range, returns a value-initialized temporary (usually 0). Deduces the correct type for the initializer, which reduces risk of truncation and incorrect results.

Parameters
[in]firstBeginning of range
[in]lastEnd of range
[in]opThe fold operation
Returns
The sum of the input range.

Definition at line 216 of file algorithm.h.

◆ sum() [3/3]

template<typename Range >
constexpr auto kblib::sum ( Range &&  r) -> auto
constexpr

Sum a range.

Convenience wrapper for std::accumulate. For an empty range, returns a value-initialized temporary (usually 0). Deduces the correct type for the initializer, which reduces risk of truncation and incorrect results.

Parameters
[in]rThe range to sum
Returns
The sum of the input range.

Definition at line 237 of file algorithm.h.

◆ tau()

template<typename T >
constexpr auto kblib::tau ( ) -> T
constexpr

Definition at line 344 of file stats.h.

◆ tee()

template<typename StreamA , typename StreamB >
auto kblib::tee ( StreamA &  a,
StreamB &  b 
) -> basic_teestream<StreamA, StreamB>

Definition at line 552 of file io.h.

◆ time_to_str()

template<int maxBufLen = 4096, typename clock , typename duration >
auto kblib::time_to_str ( std::chrono::time_point< clock, duration > &  tp,
const std::string &  fmt = "%F %T" 
) -> std::string

Definition at line 246 of file convert.h.

◆ tmpfile()

template<typename File = std::fstream>
auto kblib::tmpfile ( const std::filesystem::path &  path,
std::ios_base::openmode  mode = std::ios_base::in | std::ios_base::out 
)

Definition at line 590 of file io.h.

◆ to_bytes()

template<typename Integral , typename CharT >
constexpr auto kblib::to_bytes ( Integral  val,
CharT(&)  dest[sizeof(Integral)] 
) -> void
constexprnoexcept

Definition at line 80 of file hash.h.

◆ to_bytes_be()

template<typename Integral , typename CharT >
constexpr auto kblib::to_bytes_be ( Integral  ival,
CharT(&)  dest[sizeof(Integral)] 
) -> void
constexprnoexcept

Definition at line 68 of file hash.h.

◆ to_bytes_le()

template<typename Integral , typename CharT >
constexpr auto kblib::to_bytes_le ( Integral  ival,
CharT(&)  dest[sizeof(Integral)] 
) -> void
constexprnoexcept

Definition at line 56 of file hash.h.

◆ to_pointer()

template<typename P >
constexpr auto kblib::to_pointer ( P &&  p) -> auto*
constexprnoexcept

Gets a raw pointer out of any smart pointer or iterator you might pass in, without dereferencing it or relying on a get() method.

Parameters
pA smart pointer to extract from.

Definition at line 71 of file iterators.h.

◆ to_signed()

template<typename I >
constexpr auto kblib::to_signed ( x) -> std::make_signed_t<I>
constexpr

Cast integral argument to corresponding signed type.

Definition at line 592 of file fakestd.h.

◆ to_string() [1/2]

template<int base, typename Int >
auto kblib::to_string ( Int  num) -> std::string

Definition at line 71 of file convert.h.

◆ to_string() [2/2]

template<typename Int >
auto kblib::to_string ( Int  num,
int  base 
) -> std::string

Definition at line 94 of file convert.h.

◆ to_unique() [1/2]

template<typename T >
auto kblib::to_unique ( gsl::owner< T * >  p) -> std::unique_ptr<T>

Definition at line 572 of file fakestd.h.

◆ to_unique() [2/2]

template<typename T , typename D >
auto kblib::to_unique ( gsl::owner< T * >  p,
D &&  d 
) -> std::unique_ptr<T, D>

Definition at line 576 of file fakestd.h.

◆ to_unsigned()

template<typename I >
constexpr auto kblib::to_unsigned ( x) -> std::make_unsigned_t<I>
constexpr

Cast integral argument to corresponding unsigned type.

Definition at line 585 of file fakestd.h.

◆ tolower()

template<typename string >
constexpr auto kblib::tolower ( string  str) -> string
constexpr

Folds all characters in a string using the default execution character set to lowercase.

Parameters
strThe string to case-fold.
Returns
string The case-folded string.

Definition at line 591 of file stringops.h.

◆ toStr() [1/2]

auto kblib::toStr ( std::string  val) -> std::string
inline

Definition at line 747 of file convert.h.

◆ toStr() [2/2]

template<typename T >
auto kblib::toStr ( val) -> std::string

Definition at line 742 of file convert.h.

◆ toupper()

template<typename string >
auto kblib::toupper ( string  str) -> string

Folds all characters in a string using the default execution character set to uppercase.

Parameters
strThe string to case-fold.
Returns
string The case-folded string.

Definition at line 604 of file stringops.h.

◆ toUTF32()

template<typename string = std::u32string>
auto kblib::toUTF32 ( const icu::UnicodeString &  s) -> string

Converts a UnicodeString to UTF-32.

Parameters
sThe string to convert.
Returns
string The re-encoded result.

Definition at line 78 of file icu.h.

◆ toUTF8()

template<typename string = std::string>
auto kblib::toUTF8 ( const icu::UnicodeString &  s) -> string

Convert a UnicodeString to a UTF-8 string.

This functionality is present in ICU, however the interface is inelegant.

Parameters
sThe string to convert.
Returns
string The re-encoded result.

Definition at line 52 of file icu.h.

◆ transform() [1/2]

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
constexpr

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.

Remarks
The expression *d_first = kblib::invoke(binary_op, *first, *first2) must be valid and must not modify *first or *first2.
Parameters
firstThe beginning of the first input range
lastThe end of the first input range
first2The beginning of the second input range
d_firstThe beginning of the output range
binary_opThe operation to apply
Returns
OutputIt An iterator to past the last element written

Definition at line 1644 of file algorithm.h.

◆ transform() [2/2]

template<typename InputIt , typename EndIt , typename OutputIt , typename UnaryOperation >
constexpr auto kblib::transform ( InputIt  first,
EndIt  last,
OutputIt  d_first,
UnaryOperation  unary_op 
) -> OutputIt
constexpr

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.

Remarks
The expression *d_first = kblib::invoke(unary_op, *first) must be valid and must not modify *first.
Parameters
firstThe beginning of the input range
lastThe end of the input range
d_firstThe beginning of the output range
unary_opThe operation to apply
Returns
OutputIt An iterator to past the last element written

Definition at line 1617 of file algorithm.h.

◆ transform_exclusive_scan()

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,
init,
BinaryAccumulation  accum,
UnaryTransform  proj 
) -> OutputIt
constexpr

Definition at line 251 of file algorithm.h.

◆ transform_if()

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
constexpr

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.

Remarks
The expression kblib::invoke(pred, *first) must be valid and must return a type convertible to bool, and must not modify *first
The expression *d_first = kblib::invoke(unary_op, *first) must be valid and must not modify *first.
Parameters
firstThe beginning of the input range
lastThe end of the input range
d_firstThe beginning of the output range
predThe predicate to apply
unary_opThe operation to apply
Returns
OutputIt An iterator to past the last element written

Definition at line 1675 of file algorithm.h.

◆ transform_iterator()

template<typename It , typename operation >
kblib::transform_iterator ( It  ,
operation   
) -> transform_iterator< It, operation >

◆ transform_range()

template<typename It , typename EndIt , typename operation >
auto kblib::transform_range ( It  begin,
EndIt  end,
operation  op 
) -> auto
noexcept

Definition at line 1314 of file iterators.h.

◆ transformer()

template<typename base_iterator , typename operation >
auto kblib::transformer ( base_iterator  it,
operation  op 
) -> transform_iterator<base_iterator, operation>
noexcept

Factory function to make transform_iterators.

Parameters
itAn InputIterator to a range to transform.
opThe transformation to apply.
Returns
transform_iterator<base_iterator, operation>

Definition at line 1307 of file iterators.h.

◆ trim_array()

template<int trim, typename T , int N, typename Indices = std::make_integer_sequence<int, N - trim>>
constexpr auto kblib::trim_array ( const T(&)  arr[N]) -> std::array<T, N - trim>
constexpr

Truncates the last trim elements from an array.

Parameters
arrThe array to trim.
Returns
std::array<T, N - trim> The trimmed array.

Definition at line 121 of file traits.h.

◆ try_get()

template<typename Map , typename Key >
constexpr auto kblib::try_get ( Map &  map,
Key &&  key 
) -> copy_const_t<Map, typename Map::mapped_type>*
constexpr

Definition at line 67 of file containers.h.

◆ try_get_file_contents()

template<typename D = std::string, typename string >
auto kblib::try_get_file_contents ( const string &  filename) -> D

Read the entire contents of a file into a container, such as std::string or std::vector<char>. Note that it will be most efficient to read into contiguous containers, as opposed to non-contiguous containers.

Parameters
filenameThe filename to open.
Template Parameters
DA contiguous sequence container, which will be created and filled with the contents of the file to be read.
Returns
std::optional<D> The contents of the file, if reading was successful.

Definition at line 123 of file io.h.

◆ try_reserve()

template<typename C , typename std::enable_if< has_reserve_v< C >, int >::type = 0>
auto kblib::try_reserve ( C &  c,
std::size_t  s 
) -> void
noexcept

Attempt to reserve capacity in a container. No-op if unsupported.

Parameters
cThe container to modify.
sThe requested capacity.

Definition at line 239 of file traits.h.

◆ unformatted_expect()

template<typename CharT >
auto kblib::unformatted_expect ( CharT  c) -> auto

Read a character from an input stream only if it equals c. Acts as an UnformattedInputOperation, that is, it will not ignore any leading whitespace.

Definition at line 262 of file io.h.

◆ url_encode()

template<typename string >
auto kblib::url_encode ( const string &  value) -> std::string

Definition at line 495 of file convert.h.

◆ variant_cast()

template<typename To , typename From >
constexpr auto kblib::variant_cast ( From &&  v) -> To
constexpr

Promotes an input variant to a super-variant. That is, one which provides at least the same set of types.

Parameters
vThe variant to promote.
Returns
To A super-variant with the same value as v.

Definition at line 183 of file variant.h.

◆ visit() [1/2]

template<typename V , typename F , typename... Fs>
constexpr auto kblib::visit ( V &&  v,
F &&  f,
Fs &&...  fs 
) -> decltype(auto)
constexpr

Wraps std::visit to provide an interface taking one variant and any number of functors providing an overload set.

Also moves the variant to the left side of the operation, improving readability.

Parameters
vThe variant to visit over.
fsAny number of functors, which taken together as an overload set can be unambiguously called with any type in V.

Definition at line 210 of file variant.h.

◆ visit() [2/2]

template<typename V >
constexpr auto kblib::visit ( V &  v) -> auto
constexpr

Two-step visiting interface. Takes a variant, and returns an object which can be called with any number of callable arguments, builds an overload set from them, and visits the variant.

Note
The returned callable object contains a reference to v, so care must be taken to avoid dangling. However, if v is long-lived, the returned object may be stored and used to visit the same variant multiple times.
Parameters
vA variant to visit.
Returns
auto A callable object which takes callable arguments and visits the visitor.

Definition at line 321 of file variant.h.

◆ visit2()

template<typename V , typename F , typename... Fs>
constexpr auto kblib::visit2 ( V &&  v,
F &&  f,
Fs &&...  fs 
) -> decltype(auto)
constexpr

Definition at line 284 of file variant.h.

◆ visit2_nop()

template<typename V , typename F , typename... Fs>
constexpr auto kblib::visit2_nop ( V &&  v,
F &&  f,
Fs &&...  fs 
) -> void
constexpr

Definition at line 295 of file variant.h.

◆ visit_indexed()

template<typename Variant , typename... Fs>
constexpr auto kblib::visit_indexed ( Variant &&  variant,
Fs &&...  fs 
) -> decltype(auto)
constexpr

Visit a variant, but pass the index (as an integral_constant) to the visitor. This allows for a visitor of a variant with duplicated types to maintain index information.

Parameters
variantThe variant to visit.
fsAny number of functors, which taken together as an overload set can be unambiguously called with (I, A), for I = std::integral_constant<std::size_t, variant.index()> and A = std::get<variant.index()>(variant).

Definition at line 165 of file variant.h.

◆ visitor()

template<typename... Ts>
kblib::visitor ( Ts...  ) -> visitor< Ts... >

◆ zip() [1/2]

template<typename InputIt1 , typename EndIt , typename InputIt2 >
auto kblib::zip ( InputIt1  begin1,
EndIt  end1,
InputIt2  begin2 
) -> zip_iterator<InputIt1, EndIt, InputIt2>
noexcept

Iterate over two ranges in lockstep, like Python's zip.

InputIt1 and EndIt may be different types, however that breaks range-for in C++14.

Parameters
begin1,end1The first range.
begin2The beginning of the second range.
Returns
zip_iterator<InputIt1, EndIt, InputIt2> A range (and also an iterator) which represents the two ranges taken in pairs.

Definition at line 1447 of file iterators.h.

◆ zip() [2/2]

template<typename Range1 , typename Range2 >
auto kblib::zip ( Range1 &&  r1,
Range2 &&  r2 
) -> zip_iterator<decltype(begin(r1)), decltype(end(r1)), decltype(begin(r2))>
noexcept

Iterate over two ranges in lockstep, like Python's zip.

Parameters
r1The first range.
r2The second range.
Returns
zip_iterator<decltype(begin(r1)), decltype(end(r1)), decltype(begin(r2))> A range (and also an iterator) which represents the two ranges taken in pairs.

Definition at line 1463 of file iterators.h.

Variable Documentation

◆ any_void

template<typename... Ts>
constexpr bool kblib::any_void = (std::is_void_v<Ts> or ...)
constexpr

Definition at line 54 of file simple.h.

◆ bits_of

template<typename Int >
constexpr int kblib::bits_of = std::numeric_limits<Int>::digits
constexpr

Definition at line 53 of file bits.h.

◆ build_end

constexpr struct kblib::build_end_t kblib::build_end

◆ conjunction_v

template<bool... args>
constexpr bool kblib::conjunction_v = (args and ...)
inlineconstexpr

Definition at line 61 of file logic.h.

◆ contains_type_v

template<typename... Ts>
KBLIB_CONSTANT_V kblib::contains_type_v = contains_type<Ts...>::value

Definition at line 65 of file traits.h.

◆ contains_types_v

template<typename... Ts>
KBLIB_CONSTANT_V kblib::contains_types_v = contains_types<Ts...>::value

Definition at line 84 of file traits.h.

◆ eof

template<typename CharT = char>
KBLIB_CONSTANT auto kblib::eof = std::char_traits<CharT>::eof()

Names the EOF value for the given character type in std::char_traits.

Definition at line 447 of file traits.h.

◆ has_reserve_v

template<typename C , typename = void>
KBLIB_CONSTANT_V kblib::has_reserve_v = false

Definition at line 220 of file traits.h.

◆ hash_detected_v

template<typename T >
constexpr bool kblib::hash_detected_v = hash_detected<T>::value
constexpr

Definition at line 920 of file fakestd.h.

◆ hash_order

constexpr endian kblib::hash_order = detail::get_hash_order()
constexpr

Definition at line 197 of file tdecl.h.

◆ implies_v

template<bool A, bool B>
constexpr bool kblib::implies_v = implies<A, B>::value
inlineconstexpr

Equivalent to implies<A, B>::value.

Definition at line 58 of file logic.h.

◆ in_place_agg

constexpr struct kblib::in_place_agg_t kblib::in_place_agg

◆ is_aliasing_type_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_aliasing_type_v = is_aliasing_type<T>::value

Definition at line 474 of file traits.h.

◆ is_bidirectional_iterator_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_bidirectional_iterator_v = is_bidirectional_iterator<T>::value

Definition at line 366 of file traits.h.

◆ is_byte_v

template<typename T >
constexpr bool kblib::is_byte_v = false
constexpr

Definition at line 248 of file sort.h.

◆ is_contiguous_v

template<typename C , typename = void>
KBLIB_CONSTANT_V kblib::is_contiguous_v = false

Type trait to determine if a container is contiguous.

Definition at line 261 of file traits.h.

◆ is_forward_iterator_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_forward_iterator_v = is_forward_iterator<T>::value

Definition at line 353 of file traits.h.

◆ is_hashable_v

template<typename Key >
KBLIB_CONSTANT_V kblib::is_hashable_v = is_hashable<Key>::value

Definition at line 328 of file hash.h.

◆ is_input_iterator_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_input_iterator_v = is_input_iterator<T>::value

Definition at line 340 of file traits.h.

◆ is_iterable_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_iterable_v = is_iterable<T>::value

Definition at line 416 of file traits.h.

◆ is_iterator_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_iterator_v = is_iterator<T>::value

Definition at line 427 of file traits.h.

◆ is_radix_sortable_v

template<typename T >
constexpr bool kblib::is_radix_sortable_v = is_radix_sortable<T>::value
constexpr

Definition at line 240 of file sort.h.

◆ is_random_access_iterator_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_random_access_iterator_v = is_random_access_iterator<T>::value

Definition at line 380 of file traits.h.

◆ is_reference_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_reference_v = std::is_reference<T>::value

Abbreviated name for std::is_reference<T>::value for C++14.

Definition at line 434 of file traits.h.

◆ is_resizable_v

template<typename C >
KBLIB_CONSTANT_V kblib::is_resizable_v = decltype(detail::calc_resizable<C>(0))::value

True if and only if C is a resizable container.

Definition at line 214 of file traits.h.

◆ is_trivially_hashable_v

template<typename T >
KBLIB_CONSTANT_V kblib::is_trivially_hashable_v
Initial value:
= (std::is_integral<T>::value and padding_bits<T>::value == 0)
or std::is_pointer<T>::value or std::is_member_object_pointer<T>::value
or std::is_member_function_pointer<T>::value

Definition at line 410 of file hash.h.

◆ is_variant_like_v

template<typename T , typename = void>
constexpr bool kblib::is_variant_like_v = false
inlineconstexpr

Definition at line 51 of file variant.h.

◆ key_detected_v

template<typename T >
constexpr bool kblib::key_detected_v = key_detected<T>::value
constexpr

Definition at line 894 of file fakestd.h.

◆ mapped_detected_v

template<typename T >
constexpr bool kblib::mapped_detected_v = mapped_detected<T>::value
constexpr

Definition at line 907 of file fakestd.h.

◆ padding_bits_v

template<typename T >
constexpr int kblib::padding_bits_v = padding_bits<T>::value
constexpr

Definition at line 304 of file hash.h.

◆ state_size_v

template<typename T >
constexpr std::size_t kblib::state_size_v = state_size<T>::value
constexpr

Definition at line 165 of file random.h.

◆ 

KBLIB_CONSTANT { ... } kblib::swap

◆ system_endian

constexpr endian kblib::system_endian = endian::unknown
constexpr

Definition at line 181 of file tdecl.h.

◆ value_detected_v

template<typename T >
constexpr bool kblib::value_detected_v = value_detected<T>::value
constexpr

Definition at line 881 of file fakestd.h.