
23 Sep
2005
23 Sep
'05
10:06 p.m.
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?