gpt4 book ai didi

c++ - 这个 noexcept 声明有效吗?

转载 作者:搜寻专家 更新时间:2023-10-31 00:51:16 25 4
gpt4 key购买 nike

struct X
{
void f() noexcept(noexcept(g()));
void g() noexcept;
};

在 vc++ 和 clang 中,这有效,但 gcc 提示:

source_file.cpp:6:34: error: ‘g’ was not declared in this scope
void f() noexcept(noexcept(g()));
^

我认为这是 gcc 中的一个错误,而不是其他 gcc 中的一个特性。对吗?

最佳答案

您的评价是correct

Within the class member-specification, the class is regarded as complete within function bodies, default arguments, noexcept-specifiers, and default member initializers (including such things in nested classes). Otherwise it is regarded as incomplete within its own class member-specification.

在一个完整类型的范围内,g应该被unqualified name lookup找到.

关于c++ - 这个 noexcept 声明有效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55677543/

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