Boost logo

Boost :

From: Thomas Maeder (maeder_at_[hidden])
Date: 2002-01-26 06:19:36


Am 2002.01.25 21:21 schrieb(en) Peter Dimov:
>
> Yes, you could (should?) do this
>
> shared_ptr<FILE> my_fopen(const char* name, const char* mode)
> {
> if (FILE* p = fopen(name, mode))
> return shared_ptr<FILE>(p, fclose);
> else
> throw open_error(name, errno);
> }

But in general, the success of fclose() should be checked. Can
shared_ptr be used then?


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