I’m using MSVC 9.0 and have this function:
class RecipientList
{
public:
template<class T>
void fillMessageWithRecipients( typename boost::is_base_of<MsgContent, T>::type* msg );
};
template< class T >
void RecipientList::fillMessageWithRecipients( typename boost::is_base_of<MsgContent, T>::type* msg )
{
// do stuff
}
I want template type deduction to work here, so I can use it like this:
class SomeMsg : public MsgContent {};
std::auto_ptr<SomeMsg> msg( new SomeMsg );
RecipientList recipients;
recipients.fillMessageWithRecipients( msg.get() );
However I get the compiler error:
error C2783: ‘void
RecipientList::fillMessageWithRecipients(boost::is_base_of::type
*)’ : could not deduce template argument for ‘T’
I have a feeling this has something to do with the fact that the type actually being passed in is a pointer type, and not the type by itself. Any idea how I can properly get type deduction working here?
Thanks in advance.
I have the feeling you are misusing
boost::is_base_of. The nestedtypewill be eithertrue_typeorfalse_type. Neither of those two make sense to take as an argument and your pointers will not be convertible to those.What you really want: