• <small id='5UKDk'></small><noframes id='5UKDk'>

      1. <tfoot id='5UKDk'></tfoot><legend id='5UKDk'><style id='5UKDk'><dir id='5UKDk'><q id='5UKDk'></q></dir></style></legend>

        <i id='5UKDk'><tr id='5UKDk'><dt id='5UKDk'><q id='5UKDk'><span id='5UKDk'><b id='5UKDk'><form id='5UKDk'><ins id='5UKDk'></ins><ul id='5UKDk'></ul><sub id='5UKDk'></sub></form><legend id='5UKDk'></legend><bdo id='5UKDk'><pre id='5UKDk'><center id='5UKDk'></center></pre></bdo></b><th id='5UKDk'></th></span></q></dt></tr></i><div id='5UKDk'><tfoot id='5UKDk'></tfoot><dl id='5UKDk'><fieldset id='5UKDk'></fieldset></dl></div>
          <bdo id='5UKDk'></bdo><ul id='5UKDk'></ul>
      2. boost::noncopyable 的优点是什么

        What are the advantages of boost::noncopyable(boost::noncopyable 的优点是什么)

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

              <tbody id='F70Xn'></tbody>
          • <small id='F70Xn'></small><noframes id='F70Xn'>

                • 本文介绍了boost::noncopyable 的优点是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  为了防止复制一个类,你可以很容易地声明一个私有的复制构造函数/赋值运算符.但是你也可以继承boost::noncopyable.

                  To prevent copying a class, you can very easily declare a private copy constructor / assignment operators. But you can also inherit boost::noncopyable.

                  在这种情况下使用 boost 的优点/缺点是什么?

                  What are the advantages / disadvantages of using boost in this case?

                  推荐答案

                  总结别人的看法:

                  boost::noncopyable 相对于私有复制方法的优势:

                  Advantages of boost::noncopyable over private copy methods:

                  1. 它的意图更加明确和描述性.使用私有复制函数是一种比 noncopyable 需要更长的时间才能发现的习惯用法.
                  2. 代码更少/打字更少/混乱更少/出错空间更少(最简单的方法是意外提供实现).
                  3. 它在类型的元数据中嵌入了正确的含义,类似于 C# 属性.您现在可以编写一个仅接受不可复制对象的函数.
                  4. 它可能会在构建过程的早期捕获错误.错误将在编译时而不是链接时出现,以防类本身或类的朋友进行错误复制.
                  5. (几乎与 #4 相同)防止类本身或类的朋友调用私有复制方法.
                  1. It is more explicit and descriptive in the intent. Using private copy functions is an idiom that takes longer to spot than noncopyable.
                  2. It is less code / less typing / less clutter / less room for error (the easiest would be accidentally providing an implementation).
                  3. It embeds meaning right in the type's metadata, similar to a C# attribute. You can now write a function which accepts only objects which are noncopyable.
                  4. It potentially catches errors earlier in the build process. The error will be presented at compile-time rather than link-time, in the case that the class itself or friends of the class are doing the erroneous copying.
                  5. (almost the same as #4) Prevents the class itself or friends of the class from calling the private copy methods.

                  私有复制方法相对于 boost::noncopyable 的优势:

                  Advantages of private copy methods over boost::noncopyable:

                  1. 没有 boost 依赖

                  这篇关于boost::noncopyable 的优点是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to print vector#39;s data(如何打印矢量的数据)
                  Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                  How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                  MSVC++ warning flags(MSVC++ 警告标志)
                  How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                  stack overflow error in C++ program(C++程序中的堆栈溢出错误)

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

                      <tbody id='MqWf8'></tbody>

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

                        • <tfoot id='MqWf8'></tfoot>

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