If you want to test a template with several types, you can run manual instances of types, for example:
// at namespace level template class Test<int>;
Explicit instances of class templates automatically start an instance of all members, which seems to be what you want.
The real problem is that the language is intended to explicitly allow behavior that you want to avoid. When a class template is implicitly created, the compiler will only instantiate the methods that are used. The main use case for this function is that some methods may require more stringent requirements for the type of instance than others, if all methods have always been created, then the class template can only be used with those types that satisfy more stringent requirements.
By providing the compiler with only an instance of the methods that are used, the class template can be used with types that do not meet all the requirements of all methods if they meet the requirements of the methods that are actually used.
A common example is operator[] in std::map<> , for which the value_type constructor must be constructive by default ( operator[] will create a new default object, initialized if the key is not in the container and returns a reference to This). The behavior in the language allows std::map to be used for types that by default cannot be constructive unless you use operator[] (or any other member function that imposes this requirement).
source share