gpt4 book ai didi

c++ - 匿名结构作为返回类型

转载 作者:搜寻专家 更新时间:2023-10-30 23:52:56 24 4
gpt4 key购买 nike

以下代码compiles fine with vc++ 19.00.23506 (标志:/Wall/WX/Za)和 vc++ 19.10.25109.0(标志:/Wall/WX/Za/permissive-,这可以在 http://webcompiler.cloudapp.net 中检查),但是 doesn't compile with clang 3.8.0 and g++ 6.3.0 (标志:-std=c++11 -Wall -Wextra -Werror -pedantic-errors)。它是 vc++ 中的错误吗?标准是否禁止此类构造?

struct
{
}
foo()
{
return {};
}

int main()
{
}

最佳答案

MSVC 出现错误:

[dcl.fct]/9 Types shall not be defined in return or parameter types...

关于c++ - 匿名结构作为返回类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42888031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com