Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
boost::checked_delete is a compile-time-checked version of delete.
To cite from http://www.boost.org/libs/utility/checked_delete.html:
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.
|
In other words, if you use a lot of forward declarations you might choose to prefer using boost::checked_delete.
Note that std::auto_ptr does not use a checked delete. When you really need a checked delete, use boost::scoped_ptr instead (but note that boost::scoped_ptr has a slightly different interface then std::auto_ptr).
When you befriending a function template specialization (like boost::checked_delete), always explicitly add at last the <> template syntax [1].
struct MyClass |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.