Is the default Move constructor defined as noexcept?

后端 未结 1 1209
轻奢々
轻奢々 2020-12-02 10:54

It seems that a vector will check if the move constructor is labeled as noexcept before deciding on whether to move or copy elements when reallocating. Is the default move c

相关标签:
1条回答
  • 2020-12-02 11:41

    I think the answer is 15.4/14 (Exception specifications):

    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.

    Basically, it Does What You Think, and the implicitly-declared move constructor is noexcept whenever it can be.

    0 讨论(0)
提交回复
热议问题