开发者

On Exception-Safety in a Function-Call

开发者 https://www.devze.com 2023-02-05 16:48 出处:网络
Is the call to f() exception-safe? inline std::auto_ptr<C> auto_new() { return std::auto_ptr<C>(new C());

Is the call to f() exception-safe?

inline std::auto_ptr<C> auto_new() {
   return std::auto_ptr<C>(new C());
}

void f(std::auto_ptr<C> p1,
       std::auto_ptr<C> p2);

// ...
{
    f(auto_new(), auto_new());
}

In other words, does it make any dif开发者_StackOverflowference when it comes to the atomicity of the first and second auto_new() function calls if the two functions are inline?


Yes, it's exception safe; no, inline makes no difference to the sequence points guaranteed in the calling expression.

0

精彩评论

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