[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"buggy"? behaviour of g++ with nested classes of a template class
From: |
José M. Benítez |
Subject: |
"buggy"? behaviour of g++ with nested classes of a template class |
Date: |
Thu, 18 May 2006 11:28:16 +0200 |
User-agent: |
Thunderbird 1.5.0.2 (X11/20060501) |
Hi,
I am having problems using parameters of a nested class of a template
class. I have tested this with around five different versions of g++. To
illustrate it, have a look at the following code:
-------------------
template <typename T>
class list {
public:
class iterator {
};
iterator begin();
};
template <typename T>
int f(const typename list<T>::iterator & a)
{
}
int g (const list<int>::iterator & a)
{
}
int main()
{
list<int> l;
f(l.begin());
g(l.begin());
return 0;
}
-------------------
"iterator" is a nested class defined within the template class "list".
When I try to use function "f" above, the compiler complains (last used
version, g++ (GCC) 4.1.0 20060304 (Red Hat 4.1.0-3)):
"$ g++ -c prueba_arbol2.cpp
testlist.cpp: In function 'int main()':
testlist.cpp:23: error: no matching function for call to
'f(list<int>::iterator)'
"
This error corresponds to line 23, "f(l.begin())". However, there is no
problem with line 24, where explicit instantiation is used. I think
definition for template function "f" is correct, but the compiler seems
not to be able to generate the right function version. Why?
How can I get this working?
Thanks in advance.
Regards,
José M. Benítez
- "buggy"? behaviour of g++ with nested classes of a template class,
José M. Benítez <=