考虑这段代码:
typedef int type1;
typedef int type2;
template <typename>
struct some_trait;
template <>
struct some_trait<type1>
{
static const int something=1;
};
template <>
struct some_trait<type2>
{
static const int something=2;
};
它失败了,因为编译器看到的是some_trait<int>
.
解决这个问题的最佳方法是什么?