阅读背景:

为什么std: weak_ptr没有操作符->?

来源:互联网 

It could be implemented thusly:

可以这样执行:

  std::shared_ptr<T> operator->() {
      auto shared = lock();
      if(shared == nullptr) {
          throw std::bad_weak_ptr(); // or some other exception
      }
      return shared;
  }
  s



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: