Boost logo

Boost Users :

Subject: Re: [Boost-users] Template method applied to template object
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2009-03-03 13:12:13


Adrien Chauve wrote:

> Hi all,
>
> The following lines don't compile with g++ (4.3.2) whereas it's ok with msvc
> 9.
>
>
> struct Foo
> {
> template<class T>
> unsigned int foo() const
> {
> return sizeof(T);
> }
>
> };
>
>
> struct OtherFoo
> {
> template<class T>
> void f(const T& t)
> {
> t.foo<double>();
> }
>
> };
>
> int main()
> {
> Foo foo;
> OtherFoo other;
> other.f<Foo>(foo);
>
> return 0;
> }
>
> The ouput is :
> test.cpp: In member function ‘void OtherFoo::f(const T&)’:
> test.cpp:17: erreur: expected primary-expression before ‘double’
> test.cpp:17: erreur: expected `;' before ‘double’
>
>
> Does anybody know a workaround ?

Is this a C++ Boost question?

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net