Index: boost/noncopyable.hpp =================================================================== diff --git a/trunk/boost/noncopyable.hpp b/trunk/boost/noncopyable.hpp --- a/trunk/boost/noncopyable.hpp (revision 77046) +++ b/trunk/boost/noncopyable.hpp (working copy) @@ -9,6 +9,8 @@ #ifndef BOOST_NONCOPYABLE_HPP_INCLUDED #define BOOST_NONCOPYABLE_HPP_INCLUDED +#include + namespace boost { // Private copy constructor and copy assignment ensure classes derived from @@ -21,11 +23,21 @@ class noncopyable { protected: +#ifndef BOOST_NO_DEFAULTED_FUNCTIONS + BOOST_CONSTEXPR noncopyable() = default; + ~noncopyable() = default; +#else noncopyable() {} ~noncopyable() {} +#endif +#ifndef BOOST_NO_DELETED_FUNCTIONS + noncopyable( const noncopyable& ) = delete; + const noncopyable& operator=( const noncopyable& ) = delete; +#else private: // emphasize the following members are private noncopyable( const noncopyable& ); const noncopyable& operator=( const noncopyable& ); +#endif }; } Index: libs/utility/utility.htm =================================================================== diff --git a/trunk/libs/utility/utility.htm b/trunk/libs/utility/utility.htm --- a/trunk/libs/utility/utility.htm (revision 77046) +++ b/trunk/libs/utility/utility.htm (working copy) @@ -84,7 +84,9 @@ will prevent the otherwise implicitly-generated functions (which don't have the proper semantics) from becoming a trap for other programmers.

The traditional way to deal with these is to declare a private copy constructor - and copy assignment, and then document why this is done.  But deriving + and copy assignment, and then document why this is done.  A new alternative + was introduced in C++2011, declaring a copy constructor and a copy assignment + operator, but marking both as deleted.  Deriving from noncopyable is simpler and clearer, and doesn't require additional documentation.

The program noncopyable_test.cpp can be used @@ -106,7 +108,9 @@ about the effect on compiler optimization of adding (even trivial inline) destructor declarations. He says "Probably this concern is misplaced, because noncopyable will be used mostly for classes which own resources and - thus have non-trivial destruction semantics."

+ thus have non-trivial destruction semantics."  With C++2011, using an + optimized and trivial constructor and similar destructor can be enforced by + declaring both and marking them default.

Function template addressof()

Function addressof() returns the address of an object.

@@ -313,7 +317,7 @@

Revised  04 September, 200818 February, 2012

© Copyright Beman Dawes 1999-2003.