74 static constexpr decltype(
auto)
call(U&&...args);
88 constexpr decltype(
auto)
operator() (U&&...)
const;
179template<
class StaticCaller,
class Functor>
180class fallback_caller {
187 template<
class Dummy,
class...T>
188 constexpr auto forward(Dummy*, T&&...args)
const
189 ->
decltype(m_functor(std::forward<T>(args)...))
191 return m_functor(std::forward<T>(args)...);
194 template<
class Dummy,
class...T>
195 constexpr decltype(
auto) forward(Dummy, T&&...args)
const {
201 constexpr fallback_caller(
const Functor& f) : m_functor(f) {}
202 constexpr fallback_caller(Functor&& f) : m_functor(std::move(f)) {}
204 fallback_caller(fallback_caller&&) =
default;
205 fallback_caller(
const fallback_caller&) =
delete;
208 constexpr decltype(
auto)
call(T&&...args)
const {
209 if constexpr ( StaticCaller::template
is_matched_v<T...> ) {
210 return StaticCaller::call(std::forward<T>(args)...);
212 auto dummy = (
int*)
nullptr;
213 return forward(dummy, std::forward<T>(args)...);
218 constexpr decltype(
auto)
operator()(T&&...args)
const {
219 return call(std::forward<T>(args)...);
277#define UGMISC_NAMED_MEMBER_TYPE_TEST(TEMPLATENAME, ALIASNAME, HASMEMBERNAME, NAME) template<class TYPE, class DEFAULTTYPE = void> \
278 class TEMPLATENAME { \
279 template<class...> struct get_defined_type; \
281 template<class V, class T, class...Ts> struct get_defined_type<V, T, Ts...> { \
282 static constexpr bool has_member = get_defined_type<void, Ts...>::has_member; \
283 using type = typename get_defined_type<void, Ts...>::type; \
286 template<class T, class...Ts> struct get_defined_type<std::void_t<typename T::NAME>, T, Ts...> { \
287 static constexpr bool has_member = true; \
288 using type = typename T::NAME; \
291 template<class V> struct get_defined_type<V> { \
292 static constexpr bool has_member = false; \
293 using type = DEFAULTTYPE; \
296 using tlist = ::ugmisc::flatten_t<void, TYPE>; \
297 using dt = typename tlist::template apply<get_defined_type>; \
300 using type = typename dt::type; \
301 static constexpr bool has_member = dt::has_member; \
304 template<class T, class D=void> \
305 using ALIASNAME = typename TEMPLATENAME<T, D>::type; \
307 template<class...T> \
308 static constexpr bool HASMEMBERNAME = TEMPLATENAME<type_list<T...>>::has_member
340#define UGMISC_MEMBER_TYPE_TEST(NAME) \
341 UGMISC_NAMED_MEMBER_TYPE_TEST(member_type_test_##NAME, member_type_##NAME, has_member_type_##NAME, NAME)
384#define UGMISC_NAMED_MEMBER_STATIC_METHOD_CALL(TEMPLATENAME, NAME) \
385 template<class...> class TEMPLATENAME; \
387 template<class FirstTry, class...Tries> \
388 struct TEMPLATENAME<FirstTry, Tries...> { \
389 template<class...> friend class TEMPLATENAME; \
392 template<class...T> struct Call : public TEMPLATENAME<Tries...>::template Call<T...> { \
395 template<class...T> struct Call<std::void_t<decltype(FirstTry::NAME(std::declval<T>()...))>, T...> { \
396 static constexpr bool is_matched = true; \
398 using matched_type = FirstTry; \
400 static constexpr decltype(auto) call(T...args) { \
401 return FirstTry::NAME(std::forward<T>(args)...); \
407 template<class...T> \
408 static constexpr decltype(auto) call(T&&...args) { \
409 return Call<void, T...>::call(std::forward<T>(args)...); \
412 template<class...T> \
413 decltype(auto) constexpr operator() (T&&...args) const { \
414 return TEMPLATENAME::call(std::forward<T>(args)...); \
419 member_::fallback_caller<TEMPLATENAME, std::remove_reference_t<F>> \
420 fallback(F&& functor) { \
421 return std::forward<F>(functor); \
424 template<class...T> \
425 using matched_type = typename Call<void, T...>::matched_type; \
427 template<class...T> \
428 static constexpr bool is_matched(T&&...) { return Call<void, T...>::is_matched; } \
430 template<class...T> \
431 static constexpr bool is_matched_v = Call<void, T...>::is_matched; \
433 template<class...T> \
434 static matched_type<T...> declval_matched(T&&...) noexcept; \
438 template<> class TEMPLATENAME<> { \
439 template<class...> friend class TEMPLATENAME; \
441 template<class...> struct Call { \
442 static constexpr bool is_matched = false; \
446 template<class...T> \
447 static constexpr bool is_matched(T&&...) { return false; } \
458#define UGMISC_MEMBER_STATIC_METHOD_CALL(NAME) \
459 UGMISC_NAMED_MEMBER_STATIC_METHOD_CALL(member_call_##NAME, NAME)
static constexpr decltype(auto) call(U &&...args)
static constexpr auto fallback(F &&functor)
??? matched_type
Definition member.hpp:129
static matched_type< U... > declval_matched(U &&...) noexcept
static constexpr bool is_matched(U &&...)
static constexpr bool is_matched_v
Definition member.hpp:136
Lists of types which may be used in some of the ugmisc templates where a single type would usually be...