Restricting templates to only certain classes?
问题 In Java you can restrict generics so that the parameter type is only a subclass of a particular class. This allows the generics to know the available functions on the type. I haven't seen this in C++ with templates. So is there a way to restrict the template type and if not, how does the intellisense know which methods are available for <typename T> and whether your passed-in type will work for the templated function? 回答1: As of C++11, there is no way to constrain template type arguments. You