Boost logo

Boost :

Subject: Re: [boost]  [type_traits] MSVC rejects typename -- why?
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-03-23 20:47:27


> Message du 24/03/11 01:01
> De : "Lorenzo Caminiti"
> A : boost_at_[hidden]
> Copie à :
> Objet : [boost]  [type_traits] MSVC rejects typename -- why?
>
> Hello all,
>
> The following code compiles on GCC (v3.4.3) but it does not on MSVC
> (cl.exe v14):
>
> #include
>
> template
> void f(T& x) {
> struct s {
> T g() {
> // GCC needs this typename but MSVC does not -- why??
> typename boost::remove_reference::type i = 0;
> return i;
> }
> };
> x = s().g();
> }
>
> MSVC does not accept the `typename` inside `s::g` because it says it's
> not within a template (but I think it is within a template...). GCC
> instead requires that `typename`.
>
> Which compiler is right? (What does the standard say?) How do I
> program this code so it works on all compilers?

here is a macro BOOST_TYPENAME in Boost.Config that was used for this purposes with old compilers.

HTH,
Vicente


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