次のコードを試しました。
template <int VAL>
void printVAL()
{
for(int i=0;i<VAL; i++){
cout << " i value is "<<i<<endl;
}
}
インスタンス化: printVAL<100>()
( std::string s ) を非型テンプレート パラメーターとして使用すると、コンパイラーは次のエラーで叫びました。
"class std::basic_str<char>' is not a valid type for a template non-type parameter.
私が知っているのは、定数の整数値のみを使用する必要があるということです。2倍にもなりません。
質問:
1) std::string を使用すべきではない理由、何が気になるのですか?
2)「外部リンケージを持つオブジェクトへのポインタを使用できる」とはどういう意味ですか? サンプルコードを入手できますか?