|
Boost Users : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-09-22 18:48:08
At 01:30 AM 9/22/2002, Darin Adler wrote:
>The rules in the C++ standard are that if you delete using a pointer in
>a context where the type of the object pointed to is not completely
>defined, the object will be deleted, but the destructor will not be
>called. Many people think that's a particularly bad rule, because the
>code compiles and runs, but does the wrong thing.
>
>Since it contains a typedef that includes sizeof(T), this function will
>fail to compile if the type T is not complete. This means that the
>checked delete function template will only compile if the destructor
>will be called. That way the compiler will detect a programming mistake
>that would otherwise result in deleting the object without calling the
>destructor. This is likely to save time that would otherwise be spent
>debugging problems caused by destructors that are not called.
Darin,
Nice description of the problem, and the solution.
>A lot of us are hoping that like a future version of the C++ standard
>will make delete itself behave like this.
While I don't following the C++ committee's Evolution Working Group
closely, I don't recall actually seeing a proposal the above. If not, maybe
you should consider writing a paper.
Cheers,
--Beman
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net