根据参考,非类型模板参数的名称是可选的,即使在分配默认值时也是如此(参见(1)和(2))。因此这些模板结构是有效的:
template <int> struct Foo {}; template <unsigned long = 42> struct Bar {};
我还没有看到访问非类型参数值的可能性。我的问题是:未命名/匿名非类型模板参数有什么意义?为什么名称是可选的?
c++ templates generic-programming non-type
c++ ×1
generic-programming ×1
non-type ×1
templates ×1