23 #include <type_traits>
28 using EnableIf = std::enable_if_t<value>;
31 using Requires = std::enable_if_t<value, bool>;
34 using Decay = std::decay_t<T>;
37 constexpr
auto isArithmetic = std::is_arithmetic_v<T>;
40 constexpr
auto isInteger = std::numeric_limits<Decay<T>>::is_integer;
43 constexpr
auto isFloatingPoint = std::is_floating_point_v<T>;
45 template<
typename From,
typename To>
46 constexpr
auto isConvertible = std::is_convertible_v<From, To>;
48 template<
typename T,
typename U>
49 constexpr
auto isSame = std::is_same_v<Decay<T>, Decay<U>>;
51 template<
typename T,
typename U>
52 constexpr
auto isBaseOf = std::is_base_of_v<Decay<T>, Decay<U>>;
57 struct isFunction {
static constexpr
auto value =
false; };
59 template<
typename Signature>
60 struct isFunction<std::function<Signature>> {
static constexpr
auto value =
true; };
65 template<
typename Ret,
typename... Args>
66 struct asFunction<Ret(Args...)> {
using type = std::function<Ret(Args...)>; };
68 template<
typename Ret,
typename... Args>
69 struct asFunction<Ret(*)(Args...)> {
using type = std::function<Ret(Args...)>; };
71 template<
typename Class,
typename Ret,
typename... Args>
72 struct asFunction<Ret(Class::*)(Args...) const> {
using type = std::function<Ret(Args...)>; };
74 template<
typename T,
typename U,
typename... Us>
75 constexpr
auto isOneOf()
77 if constexpr (
sizeof...(Us) > 0)
78 return isSame<T, U> || isOneOf<T, Us...>();
79 else return isSame<T, U>;
91 template<typename Fun>
94 template<
typename T,
typename U,
typename... Us>
95 constexpr
auto isOneOf = detail::isOneOf<T, U, Us...>();
100 namespace detail {
template<
typename T>
struct Ref {
using type = T&; }; }
105 #define REAKTORO_DEFINE_REFERENCE_TYPE_OF(basetype, reftype) \
106 namespace detail { template<> struct Ref<basetype> { using type = reftype; }; }
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
constexpr auto asFunction(const Fun &f)
Convert lambda/function pointers/member functions to std::function.
Definition: TraitsUtils.hpp:92
Definition: TraitsUtils.hpp:100
Definition: TraitsUtils.hpp:63
Definition: TraitsUtils.hpp:57