Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 2000-05-06 14:10:22


At 11:42 AM 5/6/00 -0700, Dietmar Kuehl wrote:

>> >I assume you have a class directory_iterator which contains a
>> >boost::shared_ptr member. All you should have to do is write an
>> >out-of-line destructor for directory_iterator, which gets
declared
>> >in a source (not a header) file.
>
>... and an assignment operator because the assignment operator might
>release the internal pointer, too.

Hum. Not so Cool:-(

> Anyway, thinking that a library
>should never produce a warning, not even if obscure warnings are
turned
>on, this means for gcc to also implement the copy constructor (if
>-Weffc++ is turned on, the compiler warns for a class which defines
>a copy ctor, a copy assignment, or a dtor but not all three
methods).
>
>None of these methods is particularily complex: copy or a assigning
a
>pointer isn't that hard and the destrutor can even be empty. Still,
I
>would prefer to write no extra code at all: While it isn't the case
for
>the directory iterator, in general the out of line function
definition
>isn't that nice because you need to write down all this template
header
>and such.
>
>> Cool! Why didn't I think of that?
>
>... but if everybody agrees that this is the way to go, I will take
it,
>too. After all, C++ is quite verbose at times anyway.

Well, shared_ptr is ready to use now. If the need to write the
assignment operator (and cctor) was the only problem, maybe stick
with shared_ptr.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk