can't specify templated member function with <>

Gabriel Dos Reis Gabriel.Dos-Reis@dptmaths.ens-cachan.fr
Sun Oct 25 14:50:00 GMT 1998


>>>>> «Bob», Bob Sidebotham <rns@fore.com> 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 {
	public:
		template<class F> vois iterate() { // no const F&
			F::func();
		}
	};

	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