Boost logo

Boost Users :

From: zhangwusheng (yg-boost-users_at_[hidden])
Date: 2002-09-23 09:14:47


Thanks again.
What puzzled me is the noun "complete type" and
"incompltete type",I don't catch it at first glance.

After reading the holy standard 3.9, I understand .
thanks.

"Darin Adler" <darin_at_[hidden]> wrote in message
news:6E3929AE-CDEC-11D6-AA0D-0003935B80A2_at_bentspoon.com...
>
> On Friday, September 20, 2002, at 06:34 PM, zhangwusheng wrote:
>
> > Why?And for what purpose?
> > I cannot understand the following words:
> >
> > // verify that types are complete for increased safety
>
> 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.
>
> A lot of us are hoping that like a future version of the C++ standard
> will make delete itself behave like this.
>
> -- Darin
>
>


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