C++ equivalent of using for a java parameter/return type

后端 未结 4 1984
慢半拍i
慢半拍i 2020-12-05 07:22

In java, to make a function that returns an object that is the same type as a parameter and extends a certain class, I would type:



        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 08:01

    Since I can't comment on the accepted answer, I'm providing a new answer which builds on it.

    The template parameters can be simplified by having the enable_if condition become the default type template parameter instead of nullptr.

    template::value>>
    

提交回复
热议问题