隐式移动 ctor/assignmet 操作是否例外?隐式复制操作呢?

Are the implicit move ctor/assignmet operations noexcept? What about implicit copy operations?

问题标题说明了一切。我需要知道编译器隐式实现的 default copy/move assignment/ctors 是否被声明为 noexcept.

标准说:

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.

因此,如果 class 的隐式声明 copy/move assignment/ctors 不需要调用任何标记为 noexcept(false) 的内容,那么它们将具有 noexcept(true) 说明符.需要调用的函数将是基础class的copy/moveassignment/ctors和非静态数据成员。

显然它们不能只是无条件地 noexcept,那既愚蠢又错误(例如,包含 std::string 成员的 class 的隐式复制构造函数可能需要分配内存, 所以它不能明智地是 noexcept).

如果它们只调用 noexcept 的函数,它们就是 noexcept,如果它们调用任何不是 noexcept 的函数,它们就不是 noexcept。