7namespace CXXIter::util {
11 template <
class T,
class... Ts>
12 constexpr bool are_same_v = (std::is_same_v<T, Ts> && ...);
18 template <
typename T,
template <
typename>
typename U>
19 constexpr bool is_template_instance_v =
false;
20 template <
typename T,
template <
typename>
typename U>
21 constexpr bool is_template_instance_v<U<T>, U> =
true;
30 { std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
39 template<
typename TFn,
typename... TArgs>
42 { fn(std::forward<TArgs>(args)...) };
46 inline constexpr bool is_const_reference_v = std::is_const_v<std::remove_reference_t<T>>;
48 template<
typename T>
concept is_pair =
requires(T pair) {
49 {std::get<0>(pair)} -> std::convertible_to< std::tuple_element_t<0, T> >;
50 {std::get<1>(pair)} -> std::convertible_to< std::tuple_element_t<1, T> >;
51 } && std::tuple_size_v<T> == 2;
53 template<
typename T>
concept is_optional =
requires(T optional,
typename T::value_type value) {
54 typename T::value_type;
55 {optional.value()} -> std::convertible_to<typename T::value_type>;
56 {optional.value_or(value)} -> std::convertible_to<typename T::value_type>;
65 template<
typename TContainer>
66 concept ReservableContainer =
requires(TContainer container,
size_t newSize) {
67 container.reserve(newSize);
73 template<
typename TContainer,
typename TItem>
75 typename TContainer::value_type;
76 container.push_back(item);
82 template<
template<
typename...>
typename TContainer,
typename TItem,
typename... TContainerArgs>
89 template<
typename TContainer,
typename TItem>
91 typename TContainer::value_type;
92 container.insert(item);
97 template<
template<
typename...>
typename TContainer,
typename TItem,
typename... TContainerArgs>
103 template<
typename TContainer,
typename TItemKey,
typename TItemValue>
104 concept AssocContainer =
requires(TContainer& container, std::pair<TItemKey, TItemValue> item) {
105 typename TContainer::value_type;
106 typename TContainer::key_type;
107 typename TContainer::mapped_type;
108 container.insert(item);
113 template<
template<
typename...>
typename TContainer,
typename TItemKey,
typename TItemValue,
typename... TContainerArgs>
119 template<
typename TContainer,
typename TItem>
121 typename TContainer::value_type;
122 typename TContainer::size_type;
123 {container[idx] = item};
124 {container.max_size()} -> std::same_as<typename TContainer::size_type>;
125 {container.fill(item)};
132 template<
typename TContainer>
134 typename TContainer::value_type;
135 typename TContainer::size_type;
136 {container.data()} -> std::same_as<typename TContainer::value_type*>;
Concept enforcing an associative container like std::map.
Concept enforcing an associative container like std::map.
Concept enforcing a back-insertible container like std::vector.
Concept enforcing a back-insertible container like std::vector.
Concept enforcing TContainer to be a container based on a contiguous chunk of memory containing all e...
Concept enforcing an insertible container like std::set.
Concept enforcing an insertible container like std::set.
Concept enforcing a std::array<,> template instantiation.
Concept that checks whether the given invocable type TFn is a function-type that accepts the paramete...
Concept that checks whether the given type T has an implementation of std::hash<T>::operator()