Boost logo

Boost :

From: Emil Dotchevski (emil_at_[hidden])
Date: 2007-11-03 03:30:48


> I don't think making file_entry is a lot of work. It's pretty simple and
> straightforward. And once it's made, you keep it around in your arsenal.

Not to split hairs here, but you could also write:

boost::shared_ptr<FILE> open_file( char const * name, char const * mode )
{
  if( FILE * f = fopen(name,mode) )
    return boost::shared_ptr<FILE>(f,fclose);
  else
    throw fopen_error(name,mode);
}

and keep that in your "arsenal".

In fact, I think this function would be a good addition to boost so
it's part of everyone's arsenal. :)

-- 
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode

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