nngn
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#ifndef NNGN_UTILS_TYPES_H
2#define NNGN_UTILS_TYPES_H
3
4#include "utils/utils.h"
5
6namespace nngn {
7
8namespace detail { struct types_tag; }
9
10template<typename T>
11concept type_list = std::derived_from<T, detail::types_tag>;
12
13namespace detail {
14
15struct types_tag {};
16template<typename ...Ts> struct types_impl;
17template<type_list T> struct types_first;
18template<type_list T> struct types_last;
19template<type_list T> using types_first_t = typename types_first<T>::type;
20template<type_list T> using types_last_t = typename types_last<T>::type;
21template<type_list T> using type = types_first<T>;
22template<type_list T> using type_t = types_first_t<T>;
23
24template<typename T, typename ...Ts>
25struct types_first<types_impl<T, Ts...>> : std::type_identity<T> {};
26
27template<typename ...Ts>
28struct types_last<types_impl<Ts...>>
29 : std::type_identity<types_first_t<decltype((..., types_impl<Ts>{}))>> {};
30
31template<typename ...Ts>
33 constexpr void map(auto &&f) const { (..., FWD(f)(types_impl<Ts>{})); }
34};
35
36}
37
38using detail::types_first, detail::types_first_t;
39using detail::types_last, detail::types_last_t;
41
42template<typename ...Ts> using types = detail::types_impl<Ts...>;
43
44}
45
46#endif
Definition types.h:11
#define T(f0, f1, f2)
typename types_first< T >::type types_first_t
Definition types.h:19
types_first_t< T > type_t
Definition types.h:22
types_first< T > type
Definition types.h:21
typename types_last< T >::type types_last_t
Definition types.h:20
Definition audio.cpp:7
local function f()) end
#define FWD(...)
Definition utils.h:18
Definition types.h:17
Definition types.h:32
constexpr void map(auto &&f) const
Definition types.h:33
Definition types.h:18
Definition types.h:15