|
| constexpr bool | ghassanpl::valid_index (random_access_range auto &range, std::integral auto index) |
| | Returns whether or not a given integer is a valid index to a random access range.
|
| constexpr auto | ghassanpl::modulo_index (size_t range_size, std::integral auto index) |
| | Returns index converted to a valid index into a range of range_size as if using modulo arithmetic.
|
| constexpr auto | ghassanpl::modulo_index (random_access_range auto &range, std::integral auto index) |
| | Returns an valid index into range, created from index as if range is circular.
|
| constexpr decltype(auto) | ghassanpl::at (random_access_range auto &range, std::integral auto index) |
| | Returns a reference to the value at index of range.
|
| constexpr auto | ghassanpl::at_ptr (random_access_range auto &range, std::integral auto index) -> decltype(std::to_address(std::ranges::begin(range)+index)) |
| | Returns a pointer to the value at index of range if index is valid, else returns null.
|
| constexpr decltype(auto) | ghassanpl::modulo_at (random_access_range auto &range, std::integral auto index) |
| | Returns a reference to the value at modulo_index of range.
|
template<random_access_range RANGE, typename T>
requires requires (T value, RANGE range) { { *std::ranges::begin(range) == value } -> std::convertible_to<bool>; } |
| constexpr auto | ghassanpl::index_of (RANGE const &range, T &&value) -> std::iter_difference_t< range_iterator< RANGE > > |
| | Find a value in range and returns an index to it.
|
| template<random_access_range RANGE, typename T = range_value<RANGE>> |
| constexpr auto | ghassanpl::at_or_default (RANGE &&range, std::integral auto index, T &&default_value) |
| | Return the element at index or default_value if not a valid index.
|
| template<random_access_range RANGE, typename FUNC> |
| constexpr auto | ghassanpl::find_index (RANGE const &range, FUNC &&pred) -> std::iter_difference_t< range_iterator< RANGE > > |
| | Find a value in range that matches pred, and returns an index to it.
|
| template<std::ranges::range RANGE, typename FUNC> |
| constexpr auto | ghassanpl::find_ptr (RANGE &range, FUNC &&pred) |
| | Find a value in range that matches pred, and returns a pointer to it, or null if none found.
|
| template<random_access_range RANGE, typename FUNC, typename DEF_TYPE = range_value<RANGE>> |
| auto | ghassanpl::find_if_or_default (RANGE &range, FUNC &&pred, DEF_TYPE &&default_value=DEF_TYPE{}) |
| | Find a value in range that matches pred, and returns it, or default_value if none found.
|
| constexpr auto | ghassanpl::to_index (random_access_iterator auto iterator, random_access_range auto const &range) |
| | Turns an iterator to range to an index.
|
| template<contiguous_range RANGE> |
| constexpr bool | ghassanpl::valid_address (RANGE &&range, range_value< RANGE > *pointer) |
| | Returns whether or not pointer is a valid pointer to an element in the contiguous range.
|
|
| constexpr __contains_fn | ghassanpl::contains |
| | contains(range, el)
|
| constexpr __contains_subrange_fn | ghassanpl::contains_subrange |
| | contains_subrange(range, subrange)
|
| template<class CONTAINER, std::ranges::input_range RANGE, class... TYPES> |
| constexpr CONTAINER | ghassanpl::to (RANGE &&range, TYPES &&... args) |
| | to<container>();
|
| template<template< class... > class CONTAINER, std::ranges::input_range RANGE, class... TYPES, class _Deduced = std::remove_pointer_t<decltype(detail::to_helper<CONTAINER, RANGE, TYPES...>())>> |
| constexpr _Deduced | ghassanpl::to (RANGE &&_Range, TYPES &&... ARGS) |
|
| template<typename T, size_t N = std::dynamic_extent> |
| constexpr std::pair< span< T >, span< T > > | ghassanpl::split_at (span< T, N > spn, size_t index) |
| template<typename T, size_t N = std::dynamic_extent> |
| constexpr std::array< span< T >, 3 > | ghassanpl::split_at (span< T, N > spn, size_t index, size_t size) |
| template<typename T, size_t N = std::dynamic_extent> |
| constexpr std::pair< T *, T * > | ghassanpl::as_range (span< T, N > spn) |
| constexpr auto | ghassanpl::as_span (std::ranges::range auto &range) |
| template<typename TO, typename FROM, size_t N = std::dynamic_extent> |
| auto | ghassanpl::span_cast (span< FROM, N > bytes) noexcept |
| | Casts a span of objects of type FROM to a span of objects of type TO.
|
| template<typename T1, size_t N1, typename T2, size_t N2> |
| constexpr bool | ghassanpl::are_adjacent (span< T1, N1 > s1, span< T2, N2 > s2) |
| template<typename T1, size_t N1, typename T2, size_t N2> |
| constexpr bool | ghassanpl::are_overlapping (span< T1, N1 > s1, span< T2, N2 > s2) |
| template<typename T, size_t N1, typename U, size_t N2> |
| constexpr bool | ghassanpl::ends_with (span< T, N1 > s1, span< U, N2 > s2) |
| template<typename T, size_t N1, typename U, size_t N2> |
| constexpr bool | ghassanpl::starts_with (span< T, N1 > s1, span< U, N2 > s2) |
Operations on C++20-style ranges.
template<random_access_range RANGE, typename FUNC, typename DEF_TYPE = range_value<RANGE>>
| auto ghassanpl::find_if_or_default |
( |
RANGE & | range, |
|
|
FUNC && | pred, |
|
|
DEF_TYPE && | default_value = DEF_TYPE{} ) |
|
nodiscard |
Find a value in range that matches pred, and returns it, or default_value if none found.
Definition at line 126 of file ranges.h.
template<typename TO, typename FROM, size_t N = std::dynamic_extent>
| auto ghassanpl::span_cast |
( |
span< FROM, N > | bytes | ) |
|
|
nodiscardnoexcept |
Casts a span of objects of type FROM to a span of objects of type TO.
Does not perform any checks, specifically, no alignment or size checks are performed.
Definition at line 181 of file ranges.h.