Boost logo

Boost :

From: Mike Tegtmeyer (tegtmeye_at_[hidden])
Date: 2007-11-02 19:18:51


Ah! That was news to me. I have the rationale that I needed. Thanks.

Mike

On Sat, 3 Nov 2007, Peter Dimov wrote:

> Mike Tegtmeyer:
>
>> The counter argument that I hear from not-new folks however is that it
>> takes some work to not leak the resource during an exception in the
>> shared_ptr construction. Therefore, the ugliness to maintain integrity
>> diminishes it's usefulness. ie
>>
>> FILE *in = fopen(...);
>> if(!in)
>> return/throw badness;
>>
>> //may throw here, 'in' is lost
>> shared_ptr<FILE> fin(in,fclose);
>
> The answer here is much, much easier. 'in' will not be lost. shared_ptr does
> invoke the deleter when the constructor throws.
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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