【发布时间】:2018-06-21 18:25:39
【问题描述】:
在这个video 27:35 Bryce Lelbach 给出了以下示例:
template<auto... Dims>
struct dimensions {};
struct dynamic_extent {};
constexpr dynamic_extent dyn = {};
dimensions<64, dyn, 32> d;
此代码无法编译。 GCC 抱怨:
<source>:8:27: error: 'struct dynamic_extent' is not a valid type for a template non-type parameter
dimensions<64, dyn, 32> d;
^
Clang 抱怨:
<source>:8:20: error: a non-type template parameter cannot have type 'dynamic_extent'
dimensions<64, dyn, 32> d;
^
<source>:2:22: note: template parameter is declared here
template<auto... Dims>
^
他的例子是不是完全错误(这很奇怪,因为他提到了一个使用这个想法的库)或者我没有得到什么?
【问题讨论】: