相关疑难解决方法(0)

如何确定类型是否来自模板类?

如何确定类型是否来自模板类?特别是,我需要确定模板参数是否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;
   }
}
Run Code Online (Sandbox Code Playgroud)

我敢肯定这可以做到我想不出怎么做.

c++ templates metaprogramming type-traits c++11

12
推荐指数
2
解决办法
2924
查看次数

标签 统计

c++ ×1

c++11 ×1

metaprogramming ×1

templates ×1

type-traits ×1