How do I pass a template as a template parameter to a template?

后端 未结 2 469
说谎
说谎 2021-02-05 08:34

I\'m trying to write something like:

          // I don\'t know how this particular syntax should look...
template Functo         


        
2条回答
  •  醉梦人生
    2021-02-05 09:02

    The way you use it is correct. But your function template definition itself is wrong.

    It should be this:

    template class FunctorT> //<---here is the correction
    Something MergeSomething(const Something& lhs, const Something& rhs)
    

    And Ty is not needed. In fact, its meaningless there. You can omit it completely.

    See this article by Stephen C. Dewhurst:

    • C++ Common Knowledge: Template Template Parameters

提交回复
热议问题