Ticket #6578: noncopyable_cpp11.git.2.diff

File noncopyable_cpp11.git.2.diff, 3.1 KB (added by Daryle Walker, 11 years ago)

Changes for updating noncopyable for Cxx11

  • trunk/boost/noncopyable.hpp

    diff --git a/trunk/boost/noncopyable.hpp b/trunk/boost/noncopyable.hpp
    a b  
    99#ifndef BOOST_NONCOPYABLE_HPP_INCLUDED
    1010#define BOOST_NONCOPYABLE_HPP_INCLUDED
    1111
     12#include <boost/config.hpp>
     13
    1214namespace boost {
    1315
    1416//  Private copy constructor and copy assignment ensure classes derived from
     
    2123  class noncopyable
    2224  {
    2325   protected:
     26#ifndef BOOST_NO_DEFAULTED_FUNCTIONS
     27      BOOST_CONSTEXPR noncopyable() = default;
     28      ~noncopyable() = default;
     29#else
    2430      noncopyable() {}
    2531      ~noncopyable() {}
     32#endif
     33#ifndef BOOST_NO_DELETED_FUNCTIONS
     34      noncopyable( const noncopyable& ) = delete;
     35      const noncopyable& operator=( const noncopyable& ) = delete;
     36#else
    2637   private:  // emphasize the following members are private
    2738      noncopyable( const noncopyable& );
    2839      const noncopyable& operator=( const noncopyable& );
     40#endif
    2941  };
    3042}
    3143
  • trunk/libs/utility/utility.htm

    diff --git a/trunk/libs/utility/utility.htm b/trunk/libs/utility/utility.htm
    a b  
    8484                        will prevent the otherwise implicitly-generated functions (which don't have the
    8585                        proper semantics) from becoming a trap for other programmers.</p>
    8686                <p>The traditional way to deal with these is to declare a private copy constructor
    87                         and copy assignment, and then document why this is done.&nbsp; But deriving
     87                        and copy assignment, and then document why this is done.&nbsp; A new alternative
     88                        was introduced in C++2011, declaring a copy constructor and a copy assignment
     89                        operator, but marking both as <code>delete</code>d.&nbsp; Deriving
    8890                        from <b>noncopyable</b> is simpler and clearer, and doesn't require additional
    8991                        documentation.</p>
    9092                <p>The program <a href="noncopyable_test.cpp">noncopyable_test.cpp</a> can be used
     
    106108                        about the effect on compiler optimization of adding (even trivial inline)
    107109                        destructor declarations. He says &quot;Probably this concern is misplaced,
    108110                        because noncopyable will be used mostly for classes which own resources and
    109                         thus have non-trivial destruction semantics.&quot;</p>
     111                        thus have non-trivial destruction semantics.&quot;&nbsp; With C++2011, using an
     112                        optimized and trivial constructor and similar destructor can be enforced by
     113                        declaring both and marking them <code>default</code>.</p>
    110114                <h2><a name="addressof">Function template addressof()</a></h2>
    111115                <p>Function <strong>addressof()</strong> returns the address of an object.</p>
    112116                <blockquote>
     
    313317</pre></blockquote>
    314318                <hr>
    315319                <p>Revised&nbsp; <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan
    316 -->04 September, 2008<!--webbot bot="Timestamp" endspan i-checksum="39369"
     320-->18 February, 2012<!--webbot bot="Timestamp" endspan i-checksum="39369"
    317321-->
    318322                </p>
    319323                <p>&copy; Copyright Beman Dawes 1999-2003.</p>