程序:
#include <iostream>
#include <type_traits>
template <class C>
struct tmpl
{
};
int main(int, char*[])
{
std::cout << std::is_class<tmpl<int> >::value << std::endl;
std::cout << std::is_class<tmpl<char> >::value << std::endl;
return 0;
}
输出:
1
1
但我希望编译器找出模板类 tmpl<int>
和 tmpl<char>
尚未实例化和输出0
.是否可以?我真的实例化了类模板吗 tmpl
在我的例子中?
最佳答案
通过命名您实例化的类型。一引用tmpl<SomeTypeNamedFoo>
编译器将代表您自动实例化。
关于c++ - 检查模板类实例化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15550677/