Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2000-04-07 11:01:12


Sorry, but I'm not seeing the point of this class. It seems that
you have to write something like

   struct ReleaseFile {
      void operator()(FILE* fp) {
         if (fp)
            fclose(fp);
      }
   }:

in order to write

   auto_res<FILE*,ReleaseFile> file(fopen(name,mode));

when you could almost as easily write

   struct File {
      FILE* fp;
      File(FILE* fp) : fp(fp) {}
      ~File {
         if (fp)
            fclose(fp);
      }
   }:

and then more easily write

   File file(fopen(name,mode));

Are you dealing with so many resources that wrapping up each one
is too much trouble? Perhaps then you should be lobbying for C++
to have finally blocks.


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