Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-09-23 17:06:50


Andrey Semashev wrote:

>> FILE * f = fopen( ... );
>>
>> if( f == 0 ) throw ...;
>>
>> scoped_guard file_closer = make_guard( fclose, f );
>
> In this (or similar) case I might rather make a tiny wrapper around
> FILE* instead of guard.

Interesting... when Andrei Alexandrescu and Petru Marginean introduced
ScopeGuard, this was one of their primary motivating examples, and my
initial reaction was that, indeed, biting the bullet and writing a separate
File class might be a better option.

Eliminating resource management as a motivation leaves me wondering what are
the primary uses for scope[d]_guard that you have in mind?


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