How to determine if a type is derived from a template class?

前端 未结 2 1322
太阳男子
太阳男子 2021-02-13 16:05

How can I determine if a type is derived from a template class? In particular, I need to determine if a template parameter has std::basic_ostream as a base class.

2条回答
  •  情话喂你
    2021-02-13 16:44

    Might something like Boost's is_instance_of be what you are after?

    http://www.boost.org/doc/libs/1_46_1/boost/lambda/detail/is_instance_of.hpp

    Here is the short version for 1-argument templates:

    #include 
    #include 
    
    template