Possible Duplicate:
Strings as template arguments?
Why the first declaration is OK but the second is not? Why std::string is not suitable?
template <typename T, T x> struct foo { };
using namespace std;
int main()
{
foo<int, 0> f_int; // ok
foo<string, ""> f_string; // not ok
}
I get:
error: a non-type template parameter cannot have type 'std::basic_string<char>'
using clang++.
You simply cannot have a template parameter of type
std::string. The rules for non-type template parameters are defined by the standard as follows (§14.1/4):In addition (§14.1/7):
As
std::stringis a class type, your instantiation offoois not allowed.