#ifndef MemberFunctionCheckerH #define MemberFunctionCheckerH /*------------------------------------------------------------------------------------------------------------------------------------------- MemberFunctionChecker.hpp from http://groups.google.com/group/comp.lang.c++.moderated/tree/browse_frm/thread/4f7c7a96f9afbe44/c95a7b4c645e449f#doc_e5fbc9305539f699 --------------------------------------------------------------------------------------------------------------------------------------------*/ namespace MemberFunctionChecker { template class has_member { class yes { char m;}; class no { yes m[2];}; struct BaseMixin { void operator()() {} }; struct Base : public Type, public BaseMixin {}; template class Helper {}; template static no deduce(U*, Helper* = 0); static yes deduce(...); public: static const bool result = sizeof(yes) == sizeof(deduce((Base*)(0))); }; namespace details { template class void_exp_result {}; template U const& operator,(U const&, void_exp_result); template U& operator,(U&, void_exp_result); template struct clone_constness { typedef dest_type type; }; template struct clone_constness { typedef const dest_type type; }; } template struct is_call_possible { private: class yes {}; class no { yes m[2]; }; struct derived : public type { using type::operator(); no operator()(...) const; }; typedef typename details::clone_constness::type derived_type; template struct return_value_check { static yes deduce(due_type); static no deduce(...); }; template struct return_value_check { static yes deduce(details::void_exp_result); static no deduce(...); }; template struct impl { static const bool value = false; }; template struct impl { static const bool value = sizeof( return_value_check::deduce(( ((derived_type*)0)->operator()(*(arg1*)0), details::void_exp_result())) ) == sizeof(yes); }; template struct impl { static const bool value = sizeof( return_value_check::deduce(( ((derived_type*)0)->operator()(*(arg1*)0, *(arg2*)0), details::void_exp_result())) ) == sizeof(yes); }; template struct impl { static const bool value = sizeof( return_value_check::deduce( (((derived_type*)0)->operator()(*(arg1*)0, *(arg2*)0, *(arg3*)0), details::void_exp_result())) ) == sizeof(yes); }; public: static const bool value = impl::result, call_details>::value; }; } #endif