相关疑难解决方法(0)

未命名的非类型模板参数有什么意义?

根据参考,非类型模板参数的名称是可选的,即使在分配默认值时也是如此(参见(1)和(2))。因此这些模板结构是有效的:

template <int> struct Foo {};
template <unsigned long = 42> struct Bar {};
Run Code Online (Sandbox Code Playgroud)

我还没有看到访问非类型参数值的可能性。我的问题是:未命名/匿名非类型模板参数有什么意义?为什么名称是可选的?

c++ templates generic-programming non-type

5
推荐指数
2
解决办法
329
查看次数

标签 统计

c++ ×1

generic-programming ×1

non-type ×1

templates ×1