1#ifndef TESSEACT_COMMON_SFINAE_UTILS_H
2#define TESSEACT_COMMON_SFINAE_UTILS_H
22template <
typename... Args>
27template <
typename A,
typename =
void>
38template <
typename T, T>
43template <
typename Alias,
typename AmbiguitySeed>
47 static std::array<char, 1>&
f(
decltype(&C::value));
49 static std::array<char, 2>&
f(...);
52 static_assert((
sizeof(f<AmbiguitySeed>(
nullptr)) == 1),
53 "Member name specified in AmbiguitySeed is different from member name specified in Alias, or wrong "
54 "Alias/AmbiguitySeed has been specified.");
56 static bool const value =
sizeof(f<Alias>(
nullptr)) == 2;
68#define CREATE_MEMBER_CHECK(member) \
70 template <typename T, typename = std::true_type> \
71 struct Alias_##member; \
73 template <typename T> \
74 struct Alias_##member<T, std::integral_constant<bool, tesseract_common::got_type<decltype(&T::member)>::value>> \
76 static const decltype(&T::member) value; \
79 struct AmbiguitySeed_##member \
84 template <typename T> \
85 struct has_member_##member \
87 static const bool value = \
88 tesseract_common::has_member<Alias_##member<tesseract_common::ambiguate<T, AmbiguitySeed_##member>>, \
89 Alias_##member<AmbiguitySeed_##member>>::value; \
99#define CREATE_MEMBER_FUNC_INVOCABLE_CHECK(func_name, ...) \
101 template <typename T, typename = std::true_type> \
102 struct has_member_func_invocable_##func_name : std::false_type \
106 template <typename T> \
107 struct has_member_func_invocable_##func_name< \
109 std::integral_constant<bool, std::is_invocable<decltype(&T::func_name), T, __VA_ARGS__>::value>> \
121#define CREATE_MEMBER_FUNC_RETURN_TYPE_CHECK(func_name, return_type, ...) \
123 template <typename T, typename = std::true_type> \
124 struct has_member_func_return_type_##func_name : std::false_type \
128 template <typename T> \
129 struct has_member_func_return_type_##func_name< \
131 std::integral_constant<bool, \
132 std::is_same<typename std::invoke_result<decltype(&T::func_name), T, __VA_ARGS__>::type, \
133 return_type>::value>> : std::true_type \
144#define CREATE_MEMBER_FUNC_RETURN_TYPE_NOARGS_CHECK(func_name, return_type) \
146 template <typename T, typename = std::true_type> \
147 struct has_member_func_return_type_##func_name : std::false_type \
151 template <typename T> \
152 struct has_member_func_return_type_##func_name< \
154 std::integral_constant< \
156 std::is_same<typename std::invoke_result<decltype(&T::func_name), T>::type, return_type>::value>> \
168#define CREATE_MEMBER_FUNC_SIGNATURE_CHECK(func_name, return_type, ...) \
170 template <typename T, typename = std::true_type> \
171 struct has_member_func_signature_##func_name : std::false_type \
175 template <typename T> \
176 struct has_member_func_signature_##func_name< \
178 std::integral_constant< \
180 std::is_invocable<decltype(&T::func_name), T, __VA_ARGS__>::value && \
181 std::is_same<typename std::invoke_result<decltype(&T::func_name), T, __VA_ARGS__>::type, \
182 return_type>::value>> : std::true_type \
193#define CREATE_MEMBER_FUNC_SIGNATURE_NOARGS_CHECK(func_name, return_type) \
195 template <typename T, typename = std::true_type> \
196 struct has_member_func_signature_##func_name : std::false_type \
200 template <typename T> \
201 struct has_member_func_signature_##func_name< \
203 std::integral_constant< \
205 std::is_invocable<decltype(&T::func_name), T>::value && \
206 std::is_same<typename std::invoke_result<decltype(&T::func_name), T>::type, return_type>::value>> \
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: allowed_collision_matrix.h:16
Definition: sfinae_utils.h:24
A type
Definition: sfinae_utils.h:35
Definition: sfinae_utils.h:29
Definition: sfinae_utils.h:45
static std::array< char, 1 > & f(decltype(&C::value))
static std::array< char, 2 > & f(...)
static bool const value
Definition: sfinae_utils.h:56
Definition: sfinae_utils.h:40