lin
utilities.hpp
Go to the documentation of this file.
1 // vim: set tabstop=2:softtabstop=2:shiftwidth=2:expandtab
2 
7 #ifndef LIN_CORE_TRAITS_UTILITIES_HPP_
8 #define LIN_CORE_TRAITS_UTILITIES_HPP_
9 
10 #include <type_traits>
11 
12 namespace lin {
13 namespace internal {
14 
17 template <typename...>
18 using void_t = void;
19 
20 template <template <typename...> class E, typename, typename... Ts>
21 struct _is_detected : std::false_type { };
22 
23 template <template <typename...> class E, typename... Ts>
24 struct _is_detected<E, void_t<E<Ts...>>, Ts...> : std::true_type { };
25 
43 template <template <typename...> class E, typename... Ts>
44 struct is_detected : _is_detected<E, void, Ts...> { };
45 
53 template <class... Cs>
54 struct conjunction;
55 
56 template <>
57 struct conjunction<> : std::true_type { };
58 
59 template <class C>
60 struct conjunction<C> : C { };
61 
62 template <class C, class... Cs>
63 struct conjunction<C, Cs...>
64  : std::conditional_t<C::value, conjunction<Cs...>, std::false_type> { };
65 
73 template <class... Cs>
74 struct disjunction;
75 
76 template <>
77 struct disjunction<> : std::false_type { };
78 
79 template <class C>
80 struct disjunction<C> : C { };
81 
82 template <class C, class... Cs>
83 struct disjunction<C, Cs...>
84  : std::conditional_t<C::value, std::true_type, disjunction<Cs...>> { };
85 
90 template <class C>
91 struct negation
92  : std::conditional_t<C::value, std::false_type, std::true_type> { };
93 
94 } // namespace internal
95 } // namespace lin
96 
97 #endif
Logical OR operation for template metaprogramming.
Definition: utilities.hpp:74
Logical NOT operation for template metaprogramming.
Definition: utilities.hpp:91
Tests if a given expression can be instantiated.
Definition: utilities.hpp:44
Definition: utilities.hpp:21
Logical AND operation for template metaprogramming.
Definition: utilities.hpp:54
void void_t
Template metaprogramming construct used to detect ill formed types.
Definition: utilities.hpp:18
Definition: config.hpp:27