有没有办法制作一个类型的完整副本,以便可以在模板推导上下文中区分它们?举个例子:
#include <iostream>
template <typename T>
struct test
{
static int c()
{
static int t = 0;
return t++;
}
};
typedef int handle;
int main()
{
std::cout << test<int>::c() << std::endl;
std::cout << test<handle>::c() << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
由于typedef只为类型创建别名,因此打印0,1而不是所需的0,0.是否有解决方法?