C++ templates that accept only certain types

前端 未结 14 2406
一整个雨季
一整个雨季 2020-11-22 11:37

In Java you can define generic class that accept only types that extends class of your choice, eg:

public class ObservableList {
  ...
         


        
14条回答
  •  逝去的感伤
    2020-11-22 12:05

    An equivalent that only accepts types T derived from type List looks like

    template::value>::type* = nullptr>
    class ObservableList
    {
        // ...
    };
    

提交回复
热议问题