Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
TypeList.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
4#include "../../Libraries/Foundation/Compiler.h"
5#include "../../Libraries/Foundation/TypeTraits.h"
6
7namespace SC
8{
9namespace TypeTraits
10{
11
14// clang-format off
16template <bool B, class T, class F> using ConditionalT = typename Conditional<B,T,F>::type;
17// clang-format on
18
22template <typename... TT>
24{
26 static const int size = sizeof...(TT);
27};
28
34template <typename T, int N, int M = 0>
36
43template <int N, int M, typename T, typename... TT>
44struct TypeListGet<TypeList<T, TT...>, N, M>
45{
47 using type = SC::TypeTraits::ConditionalT<N == M, T, typename TypeListGet<TypeList<TT...>, N, M + 1>::type>;
48};
49
54template <int N, int M>
55struct TypeListGet<TypeList<>, N, M>
56{
58 using type = void;
59};
60
64template <int N>
65struct TypeListGet<TypeList<>, N, 0>
66{
67};
68
73template <typename T, int N>
75
77} // namespace TypeTraits
78} // namespace SC
typename TypeListGet< T, N >::type TypeListGetT
Alias template to simplify accessing the retrieved type using TypeListGet.
Definition TypeList.h:74
typename Conditional< B, T, F >::type ConditionalT
ConditionalT is an alias template that resolves to type T if a boolean value is true,...
Definition TypeList.h:16
Retrieves the type at the specified index in the TypeList.
Definition TypeList.h:35
Represents a variadic template type list.
Definition TypeList.h:24
static const int size
Total number of types in the list.
Definition TypeList.h:26