Topic: function try block


Author: Avner Ben <avnerben@netvision.net.il>
Date: 1995/11/21
Raw View
The April DWG mentions, in the chapter on exception handling, a creature =
named
__function-try-block__. The idea, if I get it right, is to allow the =
constructor
of an assembly class to properly handle exceptions that might occur in =
the
constructors of its contained objects. Without this refinement (if the =
try block=20
is inside the ctor function block) the local handlers  will not catch it =
- only=20
handlers of the block that tried to create the object.=20
I think this is a great idea. Unfortuantely, the DWG refrains from =
bringing examples, and I am not sure I could read the BNF precisely. =
Does=20

 function-try-block:
  try ctor-initializer-opt function-body handler-seq

mean the following crazy piece of code?

 FileOfRecords::FileOfRecords(const char* name, int size)
  try {=09
  : m_file(name), m_buffer(size)
 {=20
  // do stuff
 } catch(...) {
  // handle error
 }

   Avner Ben avnerben@netvision.net.il


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]