相关疑难解决方法(0)

在自动变量破坏之前或之后创建的C++返回值?

在C++中是否保证在函数中的自动变量被销毁之前创建的返回值?公告篮::获取:

class Basket
{
public:
  // Gift is a struct containing safely copyable things like int or string
  Gift gift;
  // Used to protect access and changes to gift
  Mutex mutex;

  // Copy gift into present, while locked to be thread safe
  void put (const Gift & gift)
  {
    Lock lock(mutex);   // Constructor locks, destructor unlocks mutex
    this->gift = gift;  // Gift assignment operator
  }

  // Return a memberwise-copy of gift, tries to be thread safe (but is it?)
  Gift …
Run Code Online (Sandbox Code Playgroud)

c++ locking

19
推荐指数
2
解决办法
2674
查看次数

标签 统计

c++ ×1

locking ×1