|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-02 20:20:06
----- Original Message -----
From: "Beman Dawes" <bdawes_at_[hidden]>
To: <boost_at_[hidden]>; <boost_at_[hidden]>
Sent: Monday, April 02, 2001 7:04 PM
Subject: Re: [boost] Re: scoped_ptr: trivial dtor?
> At 12:08 PM 3/30/2001, Greg Colvin wrote:
>
> >> > > Ah, wonderful. We should put this riff in boost/utility.hpp
> >> > >
> >> > > template <class T>
> >> > > void delete_(T const volatile* x)
> >> > > {
> >> > > sizeof(T);
> >> > > delete x;
> >> > > }
> >> > >
> >> > > Then "delete x" becomes boost::delete_(x)
> >> >
> >> > Yes. Of course some compilers might complain about
> >> > the apparently useless line, so perhaps
> >> >
> >> > if (sizeof(T))
> >> > delete x;
> >> >
> >> > Regardless, a comment is in order.
> >>
> >> Good idea.
>
> Even though I don't think it applies to scoped_ptr, I think it would be a
> nice little addition to boost/utility.hpp.
>
> But the name ought to be a bit more explicit, so that readers will know by
> sight why it is used. delete_complete_type() or something.
Why? Doesn't everybody assume they are deleting the complete type when they
use built-in delete?
> Hum... Exactly when would you use it? Presumably mostly in
> templates. How does a template know if the delete requires a complete
> type?
I would use it /always/ in place of normal delete. I know somebody out there
thinks it's valuable to be able to delete pointers to things whose
definition isn't available, but I always forget that compilers are required
to let me get away with this extremely dangerous practice.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk