18 #ifndef IOX_HOOFS_CXX_TYPE_TRAITS_HPP
19 #define IOX_HOOFS_CXX_TYPE_TRAITS_HPP
21 #include <type_traits>
32 template <
typename T,
typename C>
37 template <
typename T,
typename C>
45 template <
typename T,
typename C>
46 using add_const_conditionally_t =
typename add_const_conditionally<T, C>::type;
55 constexpr
bool always_false_v =
false;
58 #if __cplusplus < 201703L && !defined(_WIN32)
59 template <
typename C,
typename... Cargs>
60 using invoke_result = std::result_of<C(Cargs...)>;
61 #elif __cplusplus >= 201703L || defined(_WIN32)
62 template <
typename C,
typename... Cargs>
63 using invoke_result = std::invoke_result<C, Cargs...>;
69 template <
typename Callable,
typename... ArgTypes>
74 template <
typename C,
typename... As>
75 static constexpr std::true_type
test(
typename cxx::invoke_result<C, As...>::type*) noexcept
81 template <
typename C,
typename... As>
82 static constexpr std::false_type
test(...) noexcept
88 static constexpr
bool value = decltype(test<Callable, ArgTypes...>(
nullptr))::value;
97 template <
typename ReturnType,
typename Callable,
typename... ArgTypes>
100 template <
typename C,
typename... As>
101 static constexpr std::true_type test(
102 std::enable_if_t<std::is_convertible<
typename cxx::invoke_result<C, As...>::type, ReturnType>::value>*) noexcept
107 template <
typename C,
typename... As>
108 static constexpr std::false_type test(...) noexcept
114 static constexpr
bool value = decltype(test<Callable, ArgTypes...>(
nullptr))::value;
120 template <
typename T>
124 template <
typename ReturnType,
typename... ArgTypes>
130 template <
typename...>
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29
Conditionally add const to type T if C has the const qualifier.
Definition: type_traits.hpp:34
Check whether T is a function pointer with arbitrary signature.
Definition: type_traits.hpp:122
Verifies whether the passed Callable type is in fact invocable with the given arguments and the resul...
Definition: type_traits.hpp:99
Verifies whether the passed Callable type is in fact invocable with the given arguments.
Definition: type_traits.hpp:71
static constexpr std::true_type test(typename cxx::invoke_result< C, As... >::type *) noexcept
Definition: type_traits.hpp:75