Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2004-03-11 02:52:18

Bronek Kozicki wrote:
> Daniel Frey <d.frey_at_[hidden]> wrote:
> [...]
> I tried following code:
> #include <iostream>
> template <typename T> class V {};
> template <template <typename> class T> struct B {};
> struct D : B<V> {};
> template <typename T>
> void f (const B<T>&)
> {
> std::cout << typeid(T).name() << std::endl;
> }
> int main()
> {
> D d;
> f (d);
> }
> According to Comeau compiler and GCC this program is invalid. I have

Yes, the code is invalid. The correct code (used in the constant
library) looks like this:

template<template <typename> class T>
void f( const B<T>& ) {}

T is than deduced to V. V is not a valid class on itself, it's just a
valid template for a template template parameter. However:

> .... however it compiles under VC71, and the output of this program is:
> class V
> I think that's a surprise?

Nope. My skills in guessing VC-bugs just seem to get better every day :)
Could you ask on some MS-support-groups about this, please? I think it's
wrong to compile the code and deduce T to V, as V is not a class. The
MS-folks should please either confirm the bug or kindly point me to the
standard text that allows this behaviour.

Regards, Daniel

Boost list run by bdawes at, gregod at, cpdaniel at, john at