Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-02-16 00:43:33


Right, so in plain C++ speak, you need typename when using
the scope operator "::", and the type on the left-hand-side
of the :: is somehow dependent on a template type argument.

Need typenames for the first two examples, but not the second two.

template <class T>
void foo1(T x) {
  typedef typename T::yow Y;
}

template <class T>
void foo2(T x) {
  typedef typename bar<T>::yow Y;
}

template <class T>
void foo3(T x) {
  typedef T Y;
}

void foo4(int x) {
  typedef bar<int>::yow Y;
}

Aleksey Gurtovoy writes:
>
> > 5. I think you may need "typename" on the "const T value_" and "T&
> > variable_", and maybe the typedefs too. I've never been able to figure
> out
> > what the requirements are. Does anyone know of a good (easily
> > understandable) reference for learning where typename is required?
> >
>
> I don't think so. From the section 14.6 [temp.res] of the standard ( para 5,
> p. 258):
>
> ... 'The keyword typename shall only be applied to qualified names, but
> those names need not be dependent.'..
>
> 'T&' and 'const T' are certainly not a 'qualified names' :)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk