can't specify templated member function with <>

Gabriel Dos Reis
Sun Oct 25 14:50:00 GMT 1998

>>>>> «Bob», Bob Sidebotham <> wrote:

Bob> I'm forced to add a dummy const F& argument, below, to the templated
Bob> member function because I can't specify it with <fun>. Is this correct
Bob> behavior?

Bob> class base {
Bob> public:
Bob>     template<class F> void iterate(const F&) {
Bob> 	F::func();
Bob>     }
Bob> };

Bob> struct fun {
Bob>     static void func() { }
Bob> };
Bob> void set() {
Bob>     base x;
Bob>     x.iterate(fun()); // works 
Bob>     x.iterate<fun>(f); // gets a "parse error before `>'"
Bob> }

I guess you mean something like this:

	class base {
		template<class F> vois iterate() { // no const F&

	struct fun {
		static void func() {}

	void set() {
		base x;
		x.iterate<fun>();	// don't work

There is a special rule for postfix expression that depends explicitly
on template arguments. It looks like this:

	x.template iterate<fun>();

Did you say funny?

-- Gaby

More information about the Gcc-bugs mailing list