Sane C++ Libraries
C++ Platform Abstraction Libraries
TypeList.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
4#include "../Foundation/Compiler.h"
5#include "../Foundation/TypeTraits.h"
6
7namespace SC
8{
9namespace TypeTraits
10{
13
17template <typename... TT>
19{
21 static const int size = sizeof...(TT);
22};
23
29template <typename T, int N, int M = 0>
31
38template <int N, int M, typename T, typename... TT>
39struct TypeListGet<TypeList<T, TT...>, N, M>
40{
42 using type = SC::TypeTraits::ConditionalT<N == M, T, typename TypeListGet<TypeList<TT...>, N, M + 1>::type>;
43};
44
49template <int N, int M>
50struct TypeListGet<TypeList<>, N, M>
51{
53 using type = void;
54};
55
59template <int N>
60struct TypeListGet<TypeList<>, N, 0>
61{
62};
63
68template <typename T, int N>
70
72} // namespace TypeTraits
73} // namespace SC
typename Conditional< B, T, F >::type ConditionalT
ConditionalT is an alias template that resolves to type T if a boolean value is true,...
Definition: TypeTraits.h:70
typename TypeListGet< T, N >::type TypeListGetT
Alias template to simplify accessing the retrieved type using TypeListGet.
Definition: TypeList.h:69
Retrieves the type at the specified index in the TypeList.
Definition: TypeList.h:30
Represents a variadic template type list.
Definition: TypeList.h:19
static const int size
Total number of types in the list.
Definition: TypeList.h:21