Compile errors with boost::mpl::if on MinGW/Msys

Hi,
I'm trying to use typedef typename boost::mpl::if_ to choose between
two structures, both with identical function names, so I can choose
which function to call based on the template parameter type.
The code works fine on Visual Studio 2005. But in MinGW/MSys it returns:
RPC3_Boost.h:203: error: template argument 2 is invalid
RPC3_Boost.h:203: error: template argument 3 is invalid
RPC3_Boost.h:203: error: ISO C++ forbids declaration of `type' with no
type
This is with boost_1_35_0. I've cut out as much code as I can:
struct ReadBitstream {
static void apply(RakNet::BitStream &bitStream, RakNet::BitStream* t)
{/* ... */}
};
template <typename T>
struct ReadPtr {
static inline void apply(RakNet::BitStream &bitStream, const char
*&t) {applyStr(bitStream, (char *&) t);}
};
template< typename T >
struct DoRead {
typedef typename boost::mpl::if_<
boost::is_convertible

________________________________________ De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de Kevin Jenkins [gameprogrammer@rakkar.org] Enviado el: miércoles, 03 de septiembre de 2008 16:47 Para: boost-users@lists.boost.org Asunto: [Boost-users] Compile errors with boost::mpl::if on MinGW/Msys
Hi,
I'm trying to use typedef typename boost::mpl::if_ to choose between two structures, both with identical function names, so I can choose which function to call based on the template parameter type.
The code works fine on Visual Studio 2005. But in MinGW/MSys it returns:
RPC3_Boost.h:203: error: template argument 2 is invalid RPC3_Boost.h:203: error: template argument 3 is invalid RPC3_Boost.h:203: error: ISO C++ forbids declaration of `type' with no type [...] typename ReadBitstream, typename ReadPtr<T> >::type type;
I'd say those typenames should go. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Kevin Jenkins wrote:
Hi,
I'm trying to use typedef typename boost::mpl::if_ to choose between two structures, both with identical function names, so I can choose which function to call based on the template parameter type. <snip>
template< typename T > struct DoRead { typedef typename boost::mpl::if_< boost::is_convertible
, typename ReadBitstream, typename ReadPtr<T> >::type type; };
You only use typename before a type that is dependant on an template
parameter. In this case it is clear that ReadBitStream and ReadPtr<T>
are types regardless of what type is substituted for T. Usually
typename is required for nested types, since template specialization can
completely change those I guess.
Microsoft is very lax about enforcing this, so you can get away with
extra typename and sometimes, IIRC, missing typename keywords.
Try this (untested)
template< typename T >
struct DoRead : boost::mpl::if_<
boost::is_convertible
participants (3)
-
JOAQUIN M. LOPEZ MUÑOZ
-
John C. Femiani
-
Kevin Jenkins