【发布时间】:2019-08-14 13:21:06
【问题描述】:
考虑this代码:
int TEN = 10;
template < typename >
struct XX
{
//static auto&& ban(auto&&...) // FAILS!?
template < typename... Args > static auto&& ban(Args&&...)
{ return TEN; }
};
int main()
{
XX<void>::ban();
return 0;
}
ban(auto&&...) 的声明因
error: invalid initialization of reference of type 'auto&&' from expression of type 'int'
使用gcc-8.3 -std=c++17 -fconcepts编译时。
那么,这是 GCC 实现中的错误吗?
请注意,当 XX 类不是模板时,它会通过。
【问题讨论】:
-
试试
-std=c++2a,不过您需要更新的 GCC 才能让它继续工作 -
@StoryTeller 也失败了。
-
@1201ProgramAlarm
error: invalid initialization of reference of type 'auto&&' from expression of type 'int' -
@Vahagn - 实时示例构建良好。在(取消)评论内容时,您可能链接到了错误的版本。
标签: c++ gcc auto perfect-forwarding c++-concepts