This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Template function calling member template of class
- From: Peter Bastian <Peter dot Bastian at iwr dot uni-heidelberg dot de>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 19 Feb 2003 11:53:29 +0100
- Subject: Template function calling member template of class
- Organization: Uni Heidelberg
Hello,
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 {
public:
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;
foo(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 dot Bastian at iwr dot uni-heidelberg dot 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 dot Bastian at iwr dot uni-heidelberg dot de Tel: +49 6221 54 4984
WWW: http://www.iwr.uni-heidelberg.de/~Peter.Bastian Fax: ... 8860