Boost logo

Boost :

From: Bronek Kozicki (brok_at_[hidden])
Date: 2004-03-11 14:50:11


Daniel Frey <daniel.frey_at_[hidden]> wrote:
> template <typename U>
> void f (const B<U>&)
> {
> U<double> v;
> v.g();
> }

There's an error:

C:\DATA\USERS\bronislaw\My Documents\msys\T248.cpp(15) : error C2143:
syntax error : missing ';' before '<'
        C:\DATA\USERS\bronislaw\My Documents\msys\T248.cpp(22) : see
reference to function template instantiation 'void f<V>(const B<T> &)'
being compiled
        with
        [
            T=V
        ]
C:\DATA\USERS\bronislaw\My Documents\msys\T248.cpp(15) : error C2143:
syntax error : missing ';' before '<'
C:\DATA\USERS\bronislaw\My Documents\msys\T248.cpp(16) : error C2065:
'v' : undeclared identifier
C:\DATA\USERS\bronislaw\My Documents\msys\T248.cpp(16) : error C2228:
left of '.g' must have class/struct/union type
        type is ''unknown-type''

I think that instead should be:

template <template <typename> class U>
void f (const B<U>&)
{
  U<double> v;
  v.g();
}

after this small change it compiles fine, and result is:
double

Regards

B.


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