Template function calling member template of class

Peter Bastian Peter.Bastian@iwr.uni-heidelberg.de
Wed Feb 19 10:57:00 GMT 2003


The code below doesn't compile with g++ (but runs
perfectly with some other compilers).

X is a class with a member template method bar.
foo is a function template calling the member template bar
with a fixed value of the template parameter.

class X {
	template<int d> 
	int bar () {return d;}

template<int x> 
int fooo () 
	return x;

template<class T>
void foo (T& g)
	int kk = fooo<17>();  // OK
	X x;
	int k = x.bar<17>();  // Not OK

int main ()
	X x;
	int k=x.bar<17>();    // OK
	int n;

Compiling with g++ (version 3.2 and 2.95.4) gives the error:
error.cc: In function `void foo(T&)':
error.cc:18: parse error before `)' token

Changing the name of the function template from foo to bar
gives the following error:
error.cc: In function `void bar(T&) [with T = int]':
error.cc:26:   instantiated from here
error.cc:18: no matching function for call to `X::bar()'

Is this a consequence of the missing implementation of
two stage lookup in templates? When will this feature be implemented?

Any reply is appreciated. 
Please CC to Peter.Bastian@iwr.uni-heidelberg.de because I am
not on the mailing list.

Thank you very much.

-- Peter
Peter Bastian, IWR,Uni Heidelberg, INF 348,R 020, 69120 Heidelberg
email: Peter.Bastian@iwr.uni-heidelberg.de   Tel: +49 6221 54 4984
WWW: http://www.iwr.uni-heidelberg.de/~Peter.Bastian Fax: ... 8860

More information about the Gcc-bugs mailing list