i18n
Translation lookup
Loading...
Searching...
No Matches
TypeTraits.hpp
Go to the documentation of this file.
1
11#pragma once
12#include <type_traits>
13#include <tuple>
14#include <cstddef>
15
26template<typename T, typename B>
27struct is_derived_from: std::integral_constant<bool, std::is_base_of<B, T>::value> {};
28
39template<typename Base, typename... Derived>
41
51template<typename Base> // (Base), n = 0
52struct all_derived<Base> : std::true_type {};
53
65template<typename Base, typename First, typename... Rest> // (Base, {Item₀, …, Itemₙ}), n ≥ 0
66struct all_derived<Base, First, Rest...> :
67 std::integral_constant<bool, //use as a type
68 std::is_base_of<Base, First>::value // is_base_of
69 && all_derived<Base, Rest...>::value> {}; // recursive
70
81template <typename T>
82struct is_tuple : std::false_type {};
83
95template <typename... Args>
96struct is_tuple<std::tuple<Args...>> : std::true_type {};
97
98
104template <std::size_t... I>
106
113template <std::size_t N, std::size_t... I>
115
121template <std::size_t... I>
123 typedef index_sequence<I...> type;
124};
Trait to check if all types in a pack are derived from a base type.
Definition TypeTraits.hpp:40
Base Type to represent a sequence of compile time indice.
Definition TypeTraits.hpp:105
Trait to check if a type T derives from a base B.
Definition TypeTraits.hpp:27
Detect whether a type is a std::tuple or not.
Definition TypeTraits.hpp:82
index_sequence< I... > type
Definition TypeTraits.hpp:123
recursive template to generate the sequence
Definition TypeTraits.hpp:114