1#ifndef KOUTIL_UTIL_TYPES_H
2#define KOUTIL_UTIL_TYPES_H
20template <
typename... T>
struct types {
21 static constexpr std::size_t
size =
sizeof...(T);
24template <
typename T>
struct are_types : std::false_type { };
26template <
typename... Types>
struct are_types<
types<Types...>> : std::true_type { };
39template <types_concept T, types_concept U>
struct types_cat;
64 typename T::template transform<int>;
65 typename T::template transform<int, int>;
66 typename T::template transform<int, int, int, int, int>;
83 template <
typename... Types>
using transform = std::tuple<Types...>;
90 template <
typename... Types>
using transform = std::variant<Types...>;
160 template <
typename T>
static constexpr std::size_t value = 0 + (std::is_same_v<T, Types> + ...);
172 return (std::is_same_v<T, Other> || ...);
235 using type = Transform::template transform<Types...>;
248 template <
typename T, std::size_t N, std::size_t I,
typename Type,
typename... Other>
250 if constexpr (std::is_same_v<T, Type>) {
251 if constexpr (N == 0) {
253 }
else if constexpr (
sizeof...(Other) != 0) {
256 }
else if constexpr (
sizeof...(Other) != 0) {
296 template <
typename... Types, std::size_t I>
297 requires(
sizeof...(Types) > 0)
299 using type = std::tuple_element_t<I, std::tuple<Types...>>;
352 template <
typename... Types,
typename Type>
353 requires(
sizeof...(Types) > 0)
362 template <std::
size_t N, types_concept Types>
struct types_view;
364 template <std::size_t N,
typename Type,
typename... Other>
struct types_view<N,
types<Type, Other...>> {
403template <types_concept Types, types_transform Transform>
412template <types_concept Types, types_container Container = types_containers::vector>
422template <types_concept Types,
typename T, std::
size_t Skip = 0>
Concept for a type that provides a container template.
Definition types.h:73
consteval bool contains_type()
Helper to check if a type is contained in a list of types.
Definition types.h:171
constexpr std::size_t types_index_of_impl()
Helper to get the index of a type in a types list.
Definition types.h:249
detail::types_get_impl< Types, I >::type types_get_t
Alias for getting a type by index in a types list.
Definition types.h:381
detail::types_to_arrays< Types, types_unique_t< Types > >::type types_to_arrays_t
Alias for converting a types list to arrays of unique types.
Definition types.h:430
constexpr bool are_types_v
Definition types.h:28
detail::unique_types_impl< Types... >::type unique_types_t
Alias for creating a unique types list from a list of types.
Definition types.h:388
detail::types_to_containers< Types, Container >::type types_to_containers_t
Alias for transforming a types list to a containers list.
Definition types.h:413
detail::types_remove< Types, T >::type types_remove_t
Definition types.h:438
detail::types_unique_impl< Types >::type types_unique_t
Alias for creating a unique types list from a types list.
Definition types.h:395
types_cat< T, U >::type types_cat_t
Alias for the concatenated types list.
Definition types.h:57
detail::types_transform_impl< Types, Transform >::type types_transform_t
Alias for transforming a types list using a transform template.
Definition types.h:404
constexpr std::size_t types_index_of_v
Gets the index of a type in a types list.
Definition types.h:423
detail::types_view< N, Types >::type types_view_t
Definition types.h:440
std::tuple_element_t< I, std::tuple< Types... > > type
Definition types.h:299
void type
Definition types.h:303
Implementation for getting a type by index in a types list.
Definition types.h:288
Structure to get the index of a type in a types list.
Definition types.h:269
types_remove_impl< Type, Types... >::type type
Definition types.h:355
std::conditional_t< std::is_same_v< Type, Search >, types<>, types< Type > > type
Definition types.h:347
types_remove_impl< Search, Other... >::type rest
Definition types.h:341
std::conditional_t< std::is_same_v< Type, Search >, rest, types_cat_t< types< Type >, rest > > type
Definition types.h:343
Implementation for converting a types list to arrays of unique types.
Definition types.h:328
Transforms a types list to a containers list.
Definition types.h:208
unique_types_impl< Types... >::type type
Definition types.h:319
Implementation for creating a unique types list from a types list.
Definition types.h:311
types_cat_t< types< Type >, std::conditional_t<(N > 1), typename types_view< N - 1, types< Other... > >::type, types<> > > type
Definition types.h:365
std::conditional_t< contains_type< T, Other... >(), other_types, types_cat_t< types< T >, other_types > > type
Definition types.h:199
unique_types_impl< Other... >::type other_types
Definition types.h:198
Implementation for creating a unique types list.
Definition types.h:180
Concatenates two types lists.
Definition types.h:39
Provides a std::vector container.
Definition types.h:136
std::vector< T > container
Definition types.h:137
A namespace containing container templates for types lists.
Definition types.h:132
A template structure to count occurrences of a specific type in a types list.
Definition types.h:146
A structure representing a variadic list of types.
Definition types.h:20
static constexpr std::size_t size
Definition types.h:21