是呼吁 f() 异常安全?

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());
}

换句话说,在第一和第二 auto_new() 功能调用如果两个函数在线?

有帮助吗?

解决方案

是的,这是例外的安全;不, inline 与调用表达式中保证的序列点没有区别。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top