This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Templates and inheritance of types


Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> writes:

> #include <vector>

> template <class T> class C : public vector<T> {
>   C( typename /*vector<T>::*/const_iterator b ) { } };

> Is it really necessary to explicitely write  vector<T>:: ?

The standard says [temp.res]/5:

5 [...] The  keyword  typename  shall only be applied to qualified
  names, but those names need not be dependent. [...]

Since const_iterator is not a qualified name, `typename' is not
acceptable.

However, if you remove the `typename' keyword, `const_iterator' would
only be considered a type if there were a global type with that name.
Hence, it appears to me that the only valid way to declare the
constructor parameter `b' is: `typename vector<T>::const_iterator b'.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]