507 #include <type_traits>
537 template<
class Base,
class Obj>
540 static std::true_type test(Base*);
541 static std::false_type test(...);
543 typedef decltype(test(
static_cast<Obj*
>(0))) TestObjType;
544 typedef decltype(test(
static_cast<void*
>(0))) TestVoidType;
562 static const bool value = TestObjType::value ==
true
563 && TestVoidType::value ==
false;
592 template <
class Base,
class Obj>
595 "Cgu::DoIf::assert_related_to_type() failed");
622 template <
class Base,
class Obj>
625 "Cgu::DoIf::assert_related_to_type() failed");
645 template <
class T1,
class T2>
648 "Cgu::DoIf::assert_same_type() failed");
673 template <
class T1,
class T2>
678 "Cgu::DoIf::assert_same_type() failed");
709 template <
class T1,
class T2>
712 "Cgu::DoIf::assert_related_types() failed");
733 static_assert(
RelatedTest<
typename std::remove_const<T>::type, T>::value,
734 "Cgu::DoIf::assert_not_const() failed");
737 #ifndef DOXYGEN_PARSING
751 template <
bool value,
class Ret>
759 struct cond_call<true, Ret> {
760 template <
class T,
class Func,
class... Args>
761 static Ret
exec(T& obj,
764 return (obj.*func)(std::forward<Args>(args)...);
767 template <
class T,
class Func,
class... Args>
768 static Ret exec_static(T& obj,
771 return func(&obj, std::forward<Args>(args)...);
778 struct cond_call<false, Ret> {
779 template <
class T,
class Func,
class... Args>
786 template <
class T,
class Func,
class... Args>
787 static Ret exec_static(T&,
797 struct cond_call<true, void> {
798 template <
class T,
class Func,
class... Args>
799 static void exec(T& obj,
802 (obj.*func)(std::forward<Args>(args)...);
805 template <
class T,
class Func,
class... Args>
806 static void exec_static(T& obj,
809 func(&obj, std::forward<Args>(args)...);
816 struct cond_call<false, void> {
817 template <
class T,
class Func,
class... Args>
822 template <
class T,
class Func,
class... Args>
823 static void exec_static(T&,
848 template <
class Base,
class Obj,
class Ret,
class... Params,
class... Args>
850 Ret (Base::*func)(Params...),
852 return cond_call<RelatedTest<Base, Obj>::value, Ret>
::exec(obj, func,
853 std::forward<Args>(args)...);
868 template <
class Base,
class Obj,
class... Params,
class... Args>
870 void (Base::*func)(Params...),
872 cond_call<RelatedTest<Base, Obj>::value,
void>
::exec(obj, func,
873 std::forward<Args>(args)...);
894 template <
class Base,
class Obj,
class Ret,
class... Params,
class... Args>
896 Ret (Base::*func)(Params...)
const,
898 return cond_call<RelatedTest<Base, Obj>::value, Ret>
::exec(obj, func,
899 std::forward<Args>(args)...);
914 template <
class Base,
class Obj,
class... Params,
class... Args>
916 void (Base::*func)(Params...)
const,
918 cond_call<RelatedTest<Base, Obj>::value,
void>
::exec(obj, func,
919 std::forward<Args>(args)...);
941 template <
class Base,
class Obj,
class Ret,
class... Params,
class... Args>
943 Ret (*func)(Base*, Params...),
945 return cond_call<RelatedTest<Base, Obj>::value, Ret>::exec_static(obj, func,
946 std::forward<Args>(args)...);
962 template <
class Base,
class Obj,
class... Params,
class... Args>
964 void (*func)(Base*, Params...),
966 cond_call<RelatedTest<Base, Obj>::value,
void>::exec_static(obj, func,
967 std::forward<Args>(args)...);