opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
non_typelist.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4
5namespace osc
6{
7 // inspired by the same ideas behind `Typelist`, but for
8 // non-type template parameters
9
10 // NonTypelist: definition
11
12 template<typename T, T...>
14
15 template<typename T>
17 };
18
19 template<typename T, T Head, T... Tails>
20 struct NonTypelist<T, Head, Tails...> {
21 static constexpr T head = Head;
22 using tails = NonTypelist<T, Tails...>;
23 };
24
25 // NonTypelist: size (the number of compile-time-values held within)
26
27 template<typename NTList>
29
30 template<typename T, T... Els>
32 static constexpr size_t value = sizeof...(Els);
33 };
34
35 template<typename NTList>
37
38 // NonTypelist: indexed access
39
40 template<typename NTList, size_t Index>
41 struct NonTypeAt;
42
43 template<typename T, T Head, T... Tails>
44 struct NonTypeAt<NonTypelist<T, Head, Tails...>, 0> {
45 static constexpr T value = Head;
46 };
47
48 template<typename T, T Head, T... Tails, size_t Index>
50 static_assert(Index < sizeof...(Tails)+1, "index out of range");
51 static constexpr T value = NonTypeAt<NonTypelist<T, Tails...>, Index-1>::value;
52 };
53}
Definition custom_decoration_generator.h:5
constexpr size_t NonTypelistSizeV
Definition non_typelist.h:36
constexpr U to(T &&value)
Definition conversion.h:56
Definition non_typelist.h:41
Definition non_typelist.h:28
Definition non_typelist.h:13