diff --git a/checked_delete.html b/checked_delete.html deleted file mode 100644 index 33b5bcb..0000000 --- a/checked_delete.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - Boost: checked_delete.hpp documentation - - - - - - - - - - - -
boost.png (6897 bytes) - -

checked_delete.hpp

-
 
-

- The header <boost/checked_delete.hpp> defines two - function templates, checked_delete and checked_array_delete, - and two class templates, checked_deleter and checked_array_deleter. -

-

The C++ Standard allows, in 5.3.5/5, pointers to incomplete class types to be - deleted with a delete-expression. When the class has a non-trivial - destructor, or a class-specific operator delete, the behavior is undefined. - Some compilers issue a warning when an incomplete type is deleted, but - unfortunately, not all do, and programmers sometimes ignore or disable - warnings.

-

A particularly troublesome case is when a smart pointer's destructor, such as - boost::scoped_ptr<T>::~scoped_ptr, is instantiated with an - incomplete type. This can often lead to silent, hard to track failures.

-

The supplied function and class templates can be used to prevent these problems, - as they require a complete type, and cause a compilation error otherwise.

-

Synopsis

-
-namespace boost
-{
-
-template<class T> void checked_delete(T * p);
-template<class T> void checked_array_delete(T * p);
-template<class T> struct checked_deleter;
-template<class T> struct checked_array_deleter;
-
-}
-
-

checked_delete

-

template<class T> void checked_delete(T * p);

-
-

- Requires: T must be a complete type. The expression delete p - must be well-formed. -

-

- Effects: delete p; -

-
-

checked_array_delete

-

template<class T> void checked_array_delete(T - * p);

-
-

- Requires: T must be a complete type. The expression delete [] p - must be well-formed. -

-

- Effects: delete [] p; -

-
-

checked_deleter

-
-template<class T> struct checked_deleter
-{
-    typedef void result_type;
-    typedef T * argument_type;
-    void operator()(T * p) const;
-};
-
-

void checked_deleter<T>::operator()(T * p) const;

-
-

- Requires: T must be a complete type. The expression delete p - must be well-formed. -

-

- Effects: delete p; -

-
-

checked_array_deleter

-
-template<class T> struct checked_array_deleter
-{
-    typedef void result_type;
-    typedef T * argument_type;
-    void operator()(T * p) const;
-};
-
-

void checked_array_deleter<T>::operator()(T * p) const;

-
-

- Requires: T must be a complete type. The expression delete [] p - must be well-formed. -

-

- Effects: delete [] p; -

-
-

Acknowledgements

-

- The function templates checked_delete and checked_array_delete - were originally part of <boost/utility.hpp>, and the - documentation acknowledged Beman Dawes, Dave Abrahams, Vladimir Prus, Rainer - Deyke, John Maddock, and others as contributors. -

-

-
- Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version - 1.0. See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt.

- - diff --git a/doc/checked_delete.qbk b/doc/checked_delete.qbk new file mode 100644 index 0000000..b168261 --- /dev/null +++ b/doc/checked_delete.qbk @@ -0,0 +1,114 @@ +[section:checked_delete Header ] + +The header ** defines two function +templates, *checked_delete* and *checked_array_delete*, and two +class templates, *checked_deleter* and *checked_array_deleter*. + +The C++ Standard allows, in 5.3.5/5, pointers to incomplete +class types to be deleted with a delete-expression. When the +class has a non-trivial destructor, or a class-specific +operator delete, the behavior is undefined. Some compilers +issue a warning when an incomplete type is deleted, but +unfortunately, not all do, and programmers sometimes ignore or +disable warnings. + +A particularly troublesome case is when a smart pointer's +destructor, such as *boost::scoped_ptr::~scoped_ptr*, is +instantiated with an incomplete type. This can often lead to +silent, hard to track failures. + +The supplied function and class templates can be used to +prevent these problems, as they require a complete type, and +cause a compilation error otherwise. + +[section Synopsis] + +`` +namespace boost +{ + template void checked_delete(T * p); + template void checked_array_delete(T * p); + template struct checked_deleter; + template struct checked_array_deleter; +} +`` + +[endsect] + +[section checked_delete] + +[section `template void checked_delete(T * p);`] + +* *Requires:* *T* must be a complete type. The expression + `delete p` must be well-formed. +* *Effects:* `delete p;` + +[endsect] + +[endsect] + +[section checked_array_delete] + +[section `template void checked_array_delete(T * p);`] + +* *Requires:* *T* must be a complete type. The expression + `delete [] p` must be well-formed. +* *Effects:* `delete [] p;` + +[endsect] + +[endsect] + +[section checked_deleter] + +`` +template struct checked_deleter +{ + typedef void result_type; + typedef T * argument_type; + void operator()(T * p) const; +}; +`` + +[section `void checked_deleter::operator()(T * p) const;`] + +* *Requires:* `T` must be a complete type. The expression + `delete p` must be well-formed. +* *Effects:* `delete p;` + +[endsect] + +[endsect] + +[section checked_array_deleter] + +`` +template struct checked_array_deleter +{ + typedef void result_type; + typedef T * argument_type; + void operator()(T * p) const; +}; +`` + +[section `void checked_array_deleter::operator()(T * p) const;`] +* *Requires:* `T` must be a complete type. The expression + `delete [] p` must be well-formed. +* `Effects:` `delete [] p;` + +[endsect] + +[endsect] + +[section Acknowledgements] + +The function templates *checked_delete* and +*checked_array_delete* were originally part of +**, and the documentation +acknowledged Beman Dawes, Dave Abrahams, +Vladimir Prus, Rainer Deyke, John Maddock, +and others as contributors. + +[endsect] + +[endsect] diff --git a/doc/core.qbk b/doc/core.qbk index e8b2fb6..530541a 100644 --- a/doc/core.qbk +++ b/doc/core.qbk @@ -30,7 +30,7 @@ Currently, the Core library contains: [`boost::addressof`] ] [ - [[@../../checked_delete.html checked_delete]] + [[link core.checked_delete checked_delete]] [`boost::checked_delete`] ] [ @@ -73,6 +73,7 @@ Currently, the Core library contains: [endsect] [include:core addressof.qbk] +[include:core checked_delete.qbk] [include:core explicit_operator_bool.qbk] [include:core lightweight_test.qbk] [include:core no_exceptions_support.qbk]