|
Boost-Commit : |
From: asutton_at_[hidden]
Date: 2007-07-24 20:53:57
Author: asutton
Date: 2007-07-24 20:53:56 EDT (Tue, 24 Jul 2007)
New Revision: 7530
URL: http://svn.boost.org/trac/boost/changeset/7530
Log:
Added examples, fleshed out concept
Text files modified:
sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/destructible.qbk | 46 +++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 1 deletions(-)
Modified: sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/destructible.qbk
==============================================================================
--- sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/destructible.qbk (original)
+++ sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/destructible.qbk 2007-07-24 20:53:56 EDT (Tue, 24 Jul 2007)
@@ -27,15 +27,59 @@
[
*Semantics:* The destructor of `t` is called, destroying
the object.
+
+ *Exceptions:* Destructors must not throw exceptions.
]
]
]
+[heading Notes]
+A class that provides a user-defined, `private` or `protected` destructor
+is not [StdDestructible].
+
+[heading Examples]
+In practice, there are very few types that are not destructible. The
+destructors of these types (whether implicitly or user-defined) are
+invoked when the lifetime of the [StdDestructible] object ends. For
+local (automatic) objects, this is when they go out of scope. For
+dynamically allocated (via `new`), this is when they are deleted. For
+static objects, this is when the program ends (maybe).
+
+ int main()
+ {
+ std::string s;
+ } // s goes out of scope, calling s.~std::string()
+
+A user-defined types are [StdDestructible] if they have an implicitly
+or user-defined destructor. In the following example, both types are
+[StdDestructible].
+
+ // This type is destructible since it explicitly provides
+ // a public destructor.
+ struct foo
+ {
+ ~foo()
+ { }
+ };
+
+ // This type is destructible since the destructor is
+ // provided by the compiler.
+ struct bar
+ { };
+
+ // This class is not destructible since the destructor
+ // is declared with private visibility.
+ class do_not_destroy
+ {
+ ~do_not_destroy()
+ { }
+ };
+
[heading C++0x]
The [StdDestructible] concept will be defined as:
// The Destructible concept requires a public desctructor,
- // either compiler-generated or user-define.
+ // either compiler-generated or user-defined.
auto concept Destructible<typename T>
{
T::~T();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk