This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Can't match void parameters for empty parms in ptr-mem-functions.


Attached is a small sample program that demonstrates a problem I'm
having. I'm running gcc-2.95.2 under ix86/Linux (RedHat 6.1). I'm
trying to instantiate a template class instance that takes as a
parameter in its constructor, a pointer to a member function that is
described by the template parameters. If that member function takes a
non-void parameter then everything's fine. If it doesn't take a
parameter, however, the compiler fails to resolve this empty parm as a
void parm.

	Any ideas?

		Ben Scherrey
//
//	match.cpp	-	Tests pointer to memberfunction void parm resolution problem.
//

template < class To, typename ReturnType, typename ParmType >
class Matcher
{
public:

	typedef ReturnType (To::*SendMethod)(ParmType) const;

	typedef ReturnType (To::*EmptyMethod)() const;

	// This constructor can't match void parm SendMethods.
	Matcher( const To& t, const SendMethod sm )
	{
		
	}

	// This constructor will work, however!
/*
	Matcher( const To& t, const EmptyMethod em )
	{
	}
*/
	
};

class Test
{
public:

	bool testVoid( void ) const { return 0; }

	bool testInt( int ) const { 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 )


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]