3

调用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()如果这两个函数是内联的,那么在第一个和第二个函数调用的原子性方面有什么区别吗?

4

1 回答 1

5

是的,这是异常安全的;不,inline对调用表达式中保证的序列点没有影响。

于 2011-01-19T08:43:23.360 回答