Purpose of boost::checked_delete
Posted
by Channel72
on Stack Overflow
See other posts from Stack Overflow
or by Channel72
Published on 2010-05-17T21:28:13Z
Indexed on
2010/05/17
21:40 UTC
Read the original article
Hit count: 225
I don't understand the purpose of boost::checked_delete. The documentation says:
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.
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.
So the C++ standard allows you to delete incomplete types, which causes undefined behavior if the type has a non-trivial destructor. What? How can an incomplete type have any destructor at all? Isn't an incomplete type just a prototype?
© Stack Overflow or respective owner