From e3e304fc219dba87c772e2700a6de61c2fa33374 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 21:06:45 +0400 Subject: [PATCH] Added Rationale section from the original docs in Boost.Utility. --- doc/addressof.qbk | 3 ++- doc/noncopyable.qbk | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/addressof.qbk b/doc/addressof.qbk index fcd5c0c..8c9cb5e 100644 --- a/doc/addressof.qbk +++ b/doc/addressof.qbk @@ -22,7 +22,8 @@ The header `` defines the function template `boost::addressof`. `boost::addressof(x)` returns the address of `x`. Ordinarily, this address can be obtained by -`&x`, but the unary `&` operator can be overloaded. +`&x`, but the unary `&` operator can be overloaded. `boost::addressof` +avoids calling used-defined `operator&()`. `boost::addressof` was originally contributed by Brad King based on ideas from discussion with Doug Gregor. diff --git a/doc/noncopyable.qbk b/doc/noncopyable.qbk index 511f0ef..9e74ba0 100644 --- a/doc/noncopyable.qbk +++ b/doc/noncopyable.qbk @@ -51,6 +51,22 @@ class X: private boost::noncopyable [endsect] +[section Rationale] + +Class noncopyable has protected constructor and destructor members to emphasize +that it is to be used only as a base class. Dave Abrahams notes concern 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.] + +With C++2011, using an optimized and trivial constructor and similar destructor +can be enforced by declaring both and marking them `default`. This is done in +the current implementation. + +[endsect] + [endsect] [endsect]