Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-07-14 09:15:43


On Saturday 14 July 2001 07:29, you wrote:
> >template<typename T> struct foo {
> > template<typename U> struct bar : public foo<U> {};
> >};
>
> Thanks that works.
>
> >I think it is the same MSVC bug as in the above ::template misparsing.
>
> MSVC
>
> >insists on finding a type (i.e. foo<U> or other<U>) but isn't satisfied by
> >
> >finding a template type parameter, so it crashes. For reference, Borland
> >fails all of these testcases.
>
> For some reason, I'm not seeing any problems with nested templates and
> VC6sp3, or with VC7b1.
>
> The following works just fine:
>
> struct UDT1{};
> struct UDT2{};
>
> template<typename T>
> struct foo
> {
> template<typename U>
> struct bar : public foo<U>
> {};
> };
>
> template <class T>
> void foo_test(T)
> {
> typedef foo<T> foo_type;
> typedef typename foo_type::template bar<UDT2> bar_type;
> foo<T> ft;
> bar_type bt;
> (void)bt;
> (void)ft;
> };
>
> int test()
> {
> foo_test(UDT1());
> return 0;
> }
>
>
>
> - John Maddock
> http://ourworld.compuserve.com/homepages/john_maddock/

I misread the code. This will work:

typedef typename foo<T>::template bar<UDT2> bar_type;

... but this would not (without lots of trickery):

typedef typename T::template bar<UDT2> bar_type;

The test code you posted looks good to me.

        Doug


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