【发布时间】:2012-11-24 17:03:42
【问题描述】:
为什么第一个声明可以,第二个不行?为什么std::string不适合?
template <typename T, T x> struct foo { };
using namespace std;
int main()
{
foo<int, 0> f_int; // ok
foo<string, ""> f_string; // not ok
}
我明白了:
error: a non-type template parameter cannot have type 'std::basic_string<char>'
使用 clang++。
【问题讨论】: