ECSTASY
All in the name
Loading...
Searching...
No Matches
Traits.hpp
Go to the documentation of this file.
1
11
12#ifndef UTIL_META_TRAITS_HPP_
13#define UTIL_META_TRAITS_HPP_
14
15#include <tuple>
16
17namespace util::meta
18{
27 template <typename... Args>
28 struct Traits {
30 using Tuple = std::tuple<Args...>;
32 static constexpr auto Size = sizeof...(Args);
34 template <std::size_t N>
35 using Nth = typename std::tuple_element<N, Tuple>::type;
36 };
37
47 template <typename Arg, typename... Args>
48 struct Traits<Arg, Args...> {
50 using Tuple = std::tuple<Arg, Args...>;
52 static constexpr size_t Size = 1 + sizeof...(Args);
54 template <std::size_t N>
55 using Nth = typename std::tuple_element<N, Tuple>::type;
57 using First = Nth<0>;
59 using Last = Nth<Size - 1>;
60 };
61
62} // namespace util::meta
63
64#endif /* !UTIL_META_TRAITS_HPP_ */
Namespace regrouping all meta programmation helper types.
Nth< Size - 1 > Last
Get the last type.
Definition Traits.hpp:59
typename std::tuple_element< N, Tuple >::type Nth
Get the type at the index N.
Definition Traits.hpp:55
Nth< 0 > First
Get the first type.
Definition Traits.hpp:57
Empty parameter pack helper type.
Definition Traits.hpp:28
typename std::tuple_element< N, Tuple >::type Nth
Get the type at the index N.
Definition Traits.hpp:35
static constexpr auto Size
Number of types.
Definition Traits.hpp:32