• <small id='QS5He'></small><noframes id='QS5He'>

  • <legend id='QS5He'><style id='QS5He'><dir id='QS5He'><q id='QS5He'></q></dir></style></legend>

    • <bdo id='QS5He'></bdo><ul id='QS5He'></ul>

      <i id='QS5He'><tr id='QS5He'><dt id='QS5He'><q id='QS5He'><span id='QS5He'><b id='QS5He'><form id='QS5He'><ins id='QS5He'></ins><ul id='QS5He'></ul><sub id='QS5He'></sub></form><legend id='QS5He'></legend><bdo id='QS5He'><pre id='QS5He'><center id='QS5He'></center></pre></bdo></b><th id='QS5He'></th></span></q></dt></tr></i><div id='QS5He'><tfoot id='QS5He'></tfoot><dl id='QS5He'><fieldset id='QS5He'></fieldset></dl></div>
        <tfoot id='QS5He'></tfoot>

        boost::shared_ptr::shared_ptr(const boost::shared_ptr&am

        时间:2023-07-19
        <tfoot id='k48GL'></tfoot>

            <tbody id='k48GL'></tbody>

          1. <i id='k48GL'><tr id='k48GL'><dt id='k48GL'><q id='k48GL'><span id='k48GL'><b id='k48GL'><form id='k48GL'><ins id='k48GL'></ins><ul id='k48GL'></ul><sub id='k48GL'></sub></form><legend id='k48GL'></legend><bdo id='k48GL'><pre id='k48GL'><center id='k48GL'></center></pre></bdo></b><th id='k48GL'></th></span></q></dt></tr></i><div id='k48GL'><tfoot id='k48GL'></tfoot><dl id='k48GL'><fieldset id='k48GL'></fieldset></dl></div>
              • <legend id='k48GL'><style id='k48GL'><dir id='k48GL'><q id='k48GL'></q></dir></style></legend>

                  <bdo id='k48GL'></bdo><ul id='k48GL'></ul>

                  <small id='k48GL'></small><noframes id='k48GL'>

                • 本文介绍了boost::shared_ptr::shared_ptr(const boost::shared_ptr&amp;)' 被隐式声明为已删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  #include <iostream>
                  #include <boost/shared_ptr.hpp>
                  #include <boost/make_shared.hpp>
                  using namespace std;
                  
                  struct Node
                  {
                      Node(int data, boost::shared_ptr<int> next = boost::make_shared<int>())
                        : m_data(data), m_next(next) {}
                  
                      int m_data;
                      boost::shared_ptr<int> m_next;    
                  };
                  

                  错误:http://www.compileonline.com/compile_cpp11_online.php- 在线编译和执行 C++11(GNU GCC 版本 4.7.2)

                  Error: http://www.compileonline.com/compile_cpp11_online.php - Compile and Execute C++11 Online (GNU GCC version 4.7.2)

                  Compiling the source code....
                  $g++ -std=c++11 main.cpp -o demo -lm -pthread -lgmpxx -lgmp -lreadline 2>&1
                  main.cpp: In constructor 'Node::Node(int, boost::shared_ptr)':
                  main.cpp:9:34: error: use of deleted function 'boost::shared_ptr::shared_ptr(const boost::shared_ptr&)'
                  In file included from /usr/include/boost/shared_ptr.hpp:17:0,
                  from main.cpp:2:
                  /usr/include/boost/smart_ptr/shared_ptr.hpp:168:25: note: 'boost::shared_ptr::shared_ptr(const boost::shared_ptr&)' is implicitly declared as deleted because 'boost::shared_ptr' declares a move constructor or move assignment operator
                  

                  问题> 我看到了帖子 Using std::shared_ptr with clang++ 和libstdc++.但是,我不知道如何修复它.

                  Question> I have see the post Using std::shared_ptr with clang++ and libstdc++. However, I don't know how to fix it.

                  该问题中发布的解决方案是向 shared_ptr 添加默认的复制构造函数和复制赋值运算符将解决该问题."

                  The solution posted in that question is "Adding a defaulted copy constructor and copy assignment operator to shared_ptr will fix the problem."

                  推荐答案

                  这是一个 错误 在旧版本的 boost::shared_ptr 中,使其与 C++11 编译器不兼容.

                  This is a bug in older versions of boost::shared_ptr that makes it incompatible with C++11 compilers.

                  最终的 C++11 标准说声明移动构造函数或移动赋值运算符会阻止复制构造函数的隐式定义,但旧版本的 boost::shared_ptr 不遵守该规则并且假设将隐式定义复制构造函数.

                  The final C++11 standard says that declaring a move constructor or move assignment operator prevents the implicit definition of a copy constructor, but older versions of boost::shared_ptr do not respect that rule and assume that a copy constructor will be implicitly defined.

                  您需要升级到 Boost 1.48 或更高版本,或者编辑 Boost 标头以将其添加到 shared_ptr:

                  You either need to upgrade to Boost version 1.48 or later, or edit the Boost headers to add this to shared_ptr:

                  shared_ptr(const shared_ptr&) = default;
                  

                  这篇关于boost::shared_ptr::shared_ptr(const boost::shared_ptr&amp;)' 被隐式声明为已删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么不是所有的 Boost 库都只有头文件? 下一篇:如何检测 boost tcp 套接字何时断开连接

                  相关文章

                    <tfoot id='8o0ea'></tfoot>
                    <legend id='8o0ea'><style id='8o0ea'><dir id='8o0ea'><q id='8o0ea'></q></dir></style></legend>

                    <i id='8o0ea'><tr id='8o0ea'><dt id='8o0ea'><q id='8o0ea'><span id='8o0ea'><b id='8o0ea'><form id='8o0ea'><ins id='8o0ea'></ins><ul id='8o0ea'></ul><sub id='8o0ea'></sub></form><legend id='8o0ea'></legend><bdo id='8o0ea'><pre id='8o0ea'><center id='8o0ea'></center></pre></bdo></b><th id='8o0ea'></th></span></q></dt></tr></i><div id='8o0ea'><tfoot id='8o0ea'></tfoot><dl id='8o0ea'><fieldset id='8o0ea'></fieldset></dl></div>

                    <small id='8o0ea'></small><noframes id='8o0ea'>

                      • <bdo id='8o0ea'></bdo><ul id='8o0ea'></ul>