Compile time type checking C++

后端 未结 3 905
春和景丽
春和景丽 2021-01-14 00:22

I have created a type list. I then create a class using a template passing the type list. When I call the print function of the class with a some types not specified they ar

3条回答
  •  时光取名叫无心
    2021-01-14 01:07

    Add a private function template

    template void print(T);
    

    which doesn't need an implementation. This should catch all types for which no explicit print exists, and since it is private, it will give an error message.

提交回复
热议问题