[comp.lang.c++] Notifying constructor failure

seanh@r4.cs.man.ac.uk (Sean Holdsworth) (09/13/90)

First apologies if this is a question that's come up before; I'm relatively
new to C++ and have not been following comp.lang.c++ for long...

I'm writing an application which involves implementing distributed virtual
memory. I have a class called Region which holds information such as the
address of the start of an area of memory, its size, protection attributes
etc. Creation of an object of class Region (which can be either on the stack
or on the heap) involves making several system calls each of which can fail
in a number of ways. It would be nice to be able to wrap up these system
calls in the class constructor but I can't figure a sensible way of returning
back to the caller information on possible failures.

My current scheme involves having a class static variable to provide this
information which must be referred to via a member function after each
call to the constructor in order to check whether the call succeeded. This
solution does not seem very elegant. Does anyone have any better solutions
to this type of problem which I suspect must arise quite often?
-----------------------------------------------------------------------------
                             Sean Holdsworth.
   EDS Group,   Room 407 IT Building,   Department of Computer Science,
   University of Manchester,   Oxford Road,  Manchester,   M13 9PL,  UK.
   Janet: seanh@uk.ac.man.cs                        Tel: +44-61-275-6294
   UUCP:  ...!uunet!mcsun!ukc!man.cs!seanh          Fax: +44-61-275-6280
   Inet:  seanh%cs.man.ac.uk@nsfnet-relay.ac.uk     Int: 6294
-----------------------------------------------------------------------------