【发布时间】:2011-08-06 22:47:42
【问题描述】:
我理解非类型模板参数应该是一个常量整数表达式。有人能解释一下为什么会这样吗?
template <std::string temp>
void foo()
{
// ...
}
error C2993: 'std::string' : illegal type for non-type template parameter 'temp'.
我了解常量积分表达式是什么。上面的 sn-p 中不允许像 std::string 这样的非常量类型的原因是什么?
【问题讨论】:
-
一个模板参数在编译时被解析。