如何确定类型是否派生自模板类?特别是,我需要确定模板参数是否std::basic_ostream
作为基类。通常std::is_base_of
是工作的工具。但是,std::is_base_of
仅适用于完整类型而不适用于类模板。
我正在寻找这样的东西。
template< typename T >
bool is_based_in_basic_ostream( T&& t )
{
if( std::is_base_of< std::basic_ostream< /*anything*/>, T >::value )
{
return true;
}
else
{
return false;
}
}
我敢肯定这可以做到,我想不出怎么做。