mirror of
https://github.com/boostorg/core.git
synced 2025-08-06 08:14:29 +02:00
Added Rationale section from the original docs in Boost.Utility.
This commit is contained in:
@@ -22,7 +22,8 @@
|
|||||||
The header `<boost/core/addressof.hpp>` defines the function
|
The header `<boost/core/addressof.hpp>` defines the function
|
||||||
template `boost::addressof`. `boost::addressof(x)` returns the
|
template `boost::addressof`. `boost::addressof(x)` returns the
|
||||||
address of `x`. Ordinarily, this address can be obtained by
|
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
|
`boost::addressof` was originally contributed by Brad King
|
||||||
based on ideas from discussion with Doug Gregor.
|
based on ideas from discussion with Doug Gregor.
|
||||||
|
@@ -51,6 +51,22 @@ class X: private boost::noncopyable
|
|||||||
|
|
||||||
[endsect]
|
[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]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
Reference in New Issue
Block a user