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<T*,RakNet::BitStream*>, 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<T*,RakNet::BitStream*>, ReadBitstream, ReadPtr<T> > {};