私はMSVC 9.0を使用しており、この機能を持っています:
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
}
ここでテンプレート型推論を機能させたいので、次のように使用できます。
class SomeMsg : public MsgContent {};
std::auto_ptr<SomeMsg> msg( new SomeMsg );
RecipientList recipients;
recipients.fillMessageWithRecipients( msg.get() );
ただし、コンパイラ エラーが発生します。
エラー C2783: 'void RecipientList::fillMessageWithRecipients(boost::is_base_of::type *)': 'T' のテンプレート引数を推測できませんでした
これは、実際に渡される型がポインター型であり、型自体ではないという事実と関係があると感じています。ここで型推論を適切に機能させる方法はありますか?
前もって感謝します。