10 #include <type_traits>
20 #define MADARA_MAKE_SUPPORT_TEST(name, var, expr) \
21 template<typename T> \
22 struct supports_##name##_impl \
24 template<typename U> \
25 static auto test(U* var) -> decltype((expr), std::true_type()); \
26 template<typename U> \
27 static auto test(...) -> std::false_type; \
28 using type = decltype(test<T>(0)); \
30 template<typename T> \
31 struct supports_##name : supports_##name##_impl<T>::type \
43 #define MADARA_MAKE_VAL_SUPPORT_TEST(name, var, expr) \
44 template<typename T> \
45 struct supports_##name##_impl \
47 template<typename U> \
48 static auto test(U var) -> decltype((expr), std::true_type()); \
49 template<typename U> \
50 static auto test(...) -> std::false_type; \
51 using type = decltype(test<T>(std::declval<T>())); \
53 template<typename T> \
54 struct supports_##name : supports_##name##_impl<T>::type \
73 template<
bool Pred,
typename T =
void>
74 using enable_if_ =
typename std::enable_if<Pred, T>::type;
78 using decay_ =
typename std::decay<T>::type;
83 template<
typename T,
typename... Args>
86 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
96 return mk_unique<V>(std::forward<T>(val));
101 template<
typename T,
typename U>
104 return std::is_same<T, U>::value;
109 template<
typename T,
typename U>
116 template<
typename Base,
typename Derived>
119 return std::is_base_of<Base, Derived>::value;
123 template<
typename Base,
typename Derived>
130 template<
typename From,
typename To>
133 return std::is_convertible<From, To>::value;
140 return std::is_integral<T>::value;
147 return std::is_floating_point<T>::value;
154 return std::is_arithmetic<T>::value;
161 return std::is_enum<T>::value;
168 return is_arithmetic<T>() || is_enum<T>();
175 return is_integral<T>() || is_enum<T>();
178 #define MADARA_AUTORET_FUNC(NAME, ARGS, ...) \
180 ARGS->::madara::utility::core::decay_<decltype(__VA_ARGS__)> \
182 return (__VA_ARGS__); \
185 #define MADARA_AUTORET_REF_FUNC(NAME, ARGS, ...) \
186 inline auto NAME ARGS->decltype(__VA_ARGS__) \
188 return (__VA_ARGS__); \
191 template<
typename Func,
typename Arg0>
193 invoke_, (Func func, Arg0&& arg0), std::forward<Arg0>(arg0).*func)
195 template<
typename Func,
typename Arg0,
typename... Args>
197 (std::forward<Arg0>(arg0).*func)(std::forward<Args>(args)...))
199 template<
typename Func,
typename... Args>
201 invoke_, (Func func, Args&&... args), func(std::forward<Args>(args)...))
#define MADARA_AUTORET_REF_FUNC(NAME, ARGS,...)
Provides utility functions and classes for common tasks and needs.
constexpr bool is_base_of()
Less verbose equivalent for std::is_base_of.
constexpr bool is_int_numeric()
Is T arithmetic or an enum?
std::unique_ptr< T > mk_unique(Args &&... args)
Creates a unique_ptr for the templated type.
typename std::enable_if< Pred, T >::type enable_if_
Less verbose synonym for std::enable_if.
constexpr bool is_enum()
Less verbose equivalent for std::is_enum.
constexpr bool is_convertible()
Less verbose equivalent for std::is_convertible.
std::unique_ptr< decay_< T > > into_unique(T &&val)
Converts a typed value into a unique_ptr of a decayed type.
constexpr bool is_same()
Less verbose equivalent for std::is_same.
constexpr bool is_arithmetic()
Less verbose equivalent for std::is_arithmetic.
constexpr bool is_integral()
Less verbose equivalent for std::is_integral.
auto invoke_(Func func, Arg0 &&arg0) -> decltype(std::forward< Arg0 >(arg0).*func)
constexpr bool is_same_decayed()
Composition of std::is_same and std::decay.
constexpr bool is_numeric()
Is T arithmetic or an enum?
typename std::decay< T >::type decay_
Less verbose synonym for std::decay.
constexpr bool is_floating_point()
Less verbose equivalent for std::is_floating_point.
constexpr bool is_base_of_decayed()
Composition of std::is_base_of and std::decay.
Copyright(c) 2020 Galois.
helper type for specifying template type parameters using a function argument instead of inside expli...