代码之家  ›  专栏  ›  技术社区  ›  abraham_hilbert

使用特定模板参数捕捉类

  •  0
  • abraham_hilbert  · 技术社区  · 6 年前

    是否可以仅捕获具有特定模板参数的类,例如:

    template< typename T >
    void foo( T<int> )
    {
      // do something
    }
    
    1 回复  |  直到 5 年前
        1
  •  4
  •   max66    6 年前

    template template 论点

    template <template <typename> class T>
    void foo( T<int> )
    {
      // do something
    }
    

    你也可以写

    template <typename...> class T
    

    T 接收零个或多个类型参数(例如:拦截 std::vector