【发布时间】:2017-09-20 17:09:00
【问题描述】:
又一个decltype(auto)模板模板参数问题。这次我能够创建的用于重现错误的最少代码如下所示:
template <template <decltype(auto)> class TT, decltype(auto) V>
void foo(TT<V>) {
};
template <decltype(auto)>
struct Bar{};
int x;
int main() {
foo(Bar<(x)>{});
}
[clang] 中的这会导致:
prog.cc:11:5: error: no matching function for call to 'foo'
foo(Bar<(x)>{});
^~~
prog.cc:2:6: note: candidate template ignored: substitution failure [with TT = Bar]: non-type template argument is not a constant expression
void foo(TT<V>) {
^
1 error generated.
[gcc] 接受代码。
据我了解,代码格式正确,clang 的解释有问题,但在向 lvvm 提交错误之前需要确认。我说的对吗?
【问题讨论】:
-
@StoryTeller 我明白你的意思。回到电脑后,我会尝试编辑问题以减少暗示性
-
@StoryTeller 我不明白你的评论。
TT是一个模板模板参数,可以推导出为Bar就好了? clang 的问题在于推导V -
@Barry - 我的评论是关于 mcve。我可以发誓 TT 是一个普通的
decltype(auto)。不是模板。显然我只是看错了。 -
更简单的例子:让
foo成为template <decltype(auto) V> void foo(Bar<V> ) { }- 相同的行为,只是少了一个变量 -
@Barry:我认为这几乎将它固化为一个clang错误,是吗?
标签: c++ templates language-lawyer c++17 template-templates