All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TemplateUtils.h
Go to the documentation of this file.
1 #ifndef TEMPLATE_UTILS_H_
2 #define TEMPLATE_UTILS_H_
3 
4 #include <type_traits>
5 
17 #define AUX_REQUIRE(what, ...) class what = typename ::std::enable_if<__VA_ARGS__>::type
18 
19 
37 #define AUX_DUMMY_ARGUMENT class = void
38 
39 namespace Aux {
40 
44 template<typename T> using decay_t = typename std::decay<T>::type;
45 
50 template<bool B> using boolToType = std::integral_constant<bool, B>;
51 
57 template<typename T1, typename T2>
58 constexpr bool isSame() {
59  return std::is_same<T1, T2>::value;
60 }
61 
67 template<typename Base, typename Derived>
68 constexpr bool isBaseOrSame() {
69  return isSame<Base, Derived>() || std::is_base_of<Base, Derived>::value;
70 }
71 
72 } // namespace Aux
73 
74 #endif
constexpr bool isBaseOrSame()
Checks whether Derived is either a type that derives from Base or is identical to Base...
Definition: TemplateUtils.h:68
typename std::decay< T >::type decay_t
This is a backport of C++14 std::decay_t.
Definition: TemplateUtils.h:44
constexpr bool isSame()
This is just a wrapper around std::is_same in order to provide a nicer interface. ...
Definition: TemplateUtils.h:58
std::integral_constant< bool, B > boolToType
Returns the corresponding std::integral_constant<bool, B> to a boolean value B.
Definition: TemplateUtils.h:50