重複の可能性:
テンプレート引数としての文字列?
最初の宣言は問題ないのに、2 番目の宣言は問題ないのはなぜですか? なぜ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>'
クラン++を使用。