gpt4 book ai didi

c++标准部分ID,其中提到析构函数隐含地没有抛出

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:30:55 24 4
gpt4 key购买 nike

我在某处读到,自 C++11 起,析构函数被隐式声明为 noexcept(true)

来自标准第12.4节

A declaration of a destructor that does not have an exception-specification has the same exception specification as if had been implicitly declared

但是在标准中的任何地方我都找不到一个部分说析构函数是隐式的 noexcept(true)。谁能指出我可以找到此信息的部分?

最佳答案

我相信您正在寻找 §15.4/14(强调我的):

An inheriting constructor (12.9) and an implicitly declared special member function (Clause 12) have an exception-specification. If f is an inheriting constructor or an implicitly declared default constructor, copy constructor, move constructor, destructor, copy assignment operator, or move assignment operator, its implicit exception-specification specifies the type-id T if and only if T is allowed by the exception-specification of a function directly invoked by f’s implicit definition; f allows all exceptions if any function it directly invokes allows all exceptions, and f has the exception-specification noexcept(true) if every function it directly invokes allows no exceptions. [ Note: It follows that f has the exception-specification noexcept(true) if it invokes no other functions. —end note ]

关于c++标准部分ID,其中提到析构函数隐含地没有抛出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28046126/

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