开发者

Constructor with by-value parameter & noexcept

In this example code:

explicit MyClass(std:开发者_如何学Python:wstring text) noexcept;

Is the use of noexcept here correct? wstring can potentially throw on construction but does the throw happen before we are in the constructor or while we are in the constructor?

EDIT: Suppose this can be generalised to any function taking a by-value parameter.


The construction and destruction of function parameters happens in the context of the caller. So no, if the construction of text throws, that is not a violation of noexcept.

Soon folks would comment and ask for a spec quote :) So I will give you 5.2.2p4

The initialization and destruction of each parameter occurs within the context of the calling function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜