【问题标题】:Boost::shared_ptr and its attributesBoost::shared_ptr 及其属性
【发布时间】:2013-11-28 21:30:47
【问题描述】:

在 boost 库下我经常看到像这样的对象

   boost::shared_ptr<std::string>
   boost:shared_ptr<tcp_connection>

   boost::enable_shared_from_this<tcp_connection>

shared_ptr 有哪些类型的属性? enable_shared_from_this 与 shared_ptr 有何关系?

【问题讨论】:

    标签: c++ boost shared-ptr


    【解决方案1】:

    Here你找到了属性。

    如果您希望能够使用this-&gt;shared_from_this() 或通常使用ptr-&gt;shared_from_this() 来获得boost::shared_ptr&lt;T&gt;,则可以从boost::enable_shared_from_this&lt;T&gt; 继承。它基本上将引用计数嵌入到 T 中,而不是将其分配到单独的位置。

    【讨论】:

      猜你喜欢
      • 2015-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-04
      • 1970-01-01
      • 2013-09-24
      • 2015-05-03
      • 1970-01-01
      相关资源
      最近更新 更多