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
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to