forked from user1095108/generic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meta.hpp
74 lines (58 loc) · 1.02 KB
/
meta.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef GNR_META_HPP
# define GNR_META_HPP
# pragma once
#include <cstddef>
#include <type_traits>
namespace gnr
{
template <std::size_t I, typename A, typename ...B>
struct type_at : type_at<I - 1, B...>
{
};
template <typename A, typename ...B>
struct type_at<0, A, B...>
{
using type = A;
};
template <typename A, typename ...B>
struct front
{
using type = A;
};
template <typename ...A>
using front_t = typename front<A...>::type;
template <typename A, typename ...B>
struct back : back<B...>
{
};
template <typename A>
struct back<A>
{
using type = A;
};
template <typename ...A>
using back_t = typename back<A...>::type;
template <class A, class ...B>
struct all_of : std::integral_constant<bool,
A{} &&
all_of<B...>{}
>
{
};
template <class A>
struct all_of<A> : std::integral_constant<bool, A{}>
{
};
template <class A, class ...B>
struct any_of : std::integral_constant<bool,
A{} ||
any_of<B...>{}
>
{
};
template <class A>
struct any_of<A> : std::integral_constant<bool, A{}>
{
};
}
#endif // GNR_META_HPP