// // match.cpp - Tests pointer to memberfunction void parm resolution problem. // template < class ReturnType, class Parm1 = void, class Parm2 = void > struct Method; template < class ReturnType, class Parm1, class Parm2 > struct Method { typedef ReturnType result_type; typedef Parm1 first_parm_type; typedef Parm2 second_parm_type; typedef ReturnType method_type( Parm1, Parm2 ); // Can't do const for some reason!!! typedef ReturnType const_method_type( Parm1, Parm2 ) const; }; template < class ReturnType, class Parm1 > struct Method< ReturnType, Parm1, void > { typedef ReturnType result_type; typedef Parm1 first_parm_type; typedef ReturnType method_type( Parm1 ); // Can't do const for some reason!!! typedef ReturnType const_method_type( Parm1 ) const; }; template < class ReturnType > struct Method< ReturnType, void, void > { typedef ReturnType result_type; typedef ReturnType method_type(); // Can't do const for some reason!!! typedef ReturnType const_method_type() const; }; template < class To, typename ReturnType, typename ParmType > class Matcher { public: // Old way... typedef ReturnType (To::*SendMethod)(ParmType) const; typedef typename Method< ReturnType, ParmType >::method_type SendMethodType; typedef SendMethodType( To::*SendMethod ); typedef ReturnType (To::*EmptyMethod)() const; // This constructor can't match void parm SendMethods. // can't do const now... Matcher( const To& t, const SendMethod sm ) Matcher( To& t, const SendMethod sm ) { } /* COMPLETELY BROKE NOW // This constructor will work, however! Matcher( const To& t, const EmptyMethod em ) { } */ }; class Test { public: // bool testVoid( void ) const { return 0; } bool testVoid( void ) { return 0; } // bool testInt( int ) const { return 0; } bool testInt( int ) { return 0; } }; int main( void ) { Test ATest; Matcher< Test, bool, void > M1( ATest, &Test::testVoid ); Matcher< Test, bool, int > M2( ATest, &Test::testInt ); } // eof( match.cpp )