
Message du 24/03/11 01:01 De : "Lorenzo Caminiti" A : boost@lists.boost.org 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