diff --git a/checked_delete.html b/checked_delete.html new file mode 100644 index 0000000..bd7753e --- /dev/null +++ b/checked_delete.html @@ -0,0 +1,124 @@ + + +
+
+
+ |
+
+ 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.
+
+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;
+
+}
+
+ +++ Requires: T must be a complete type. The expression delete p + must be well-formed. +
++ Effects: delete p; +
+
+++ Requires: T must be a complete type. The expression delete [] p + must be well-formed. +
++ Effects: delete [] p; +
+
+template<class T> struct checked_deleter
+{
+ typedef void result_type;
+ typedef T * argument_type;
+ void operator()(T * p);
+};
+
+ +++ Requires: T must be a complete type. The expression delete p + must be well-formed. +
++ Effects: delete p; +
+
+template<class T> struct checked_array_deleter
+{
+ typedef void result_type;
+ typedef T * argument_type;
+ void operator()(T * p);
+};
+
+ +++ Requires: T must be a complete type. The expression delete [] p + must be well-formed. +
++ Effects: delete [] p; +
+
+ 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. Permission to copy, use, modify, sell
+ and distribute this document is granted provided this copyright notice appears
+ in all copies. This document is provided "as is" without express or implied
+ warranty, and with no claim as to its suitability for any purpose.