Boost logo

Boost :

From: Fred Bertsch (fred.bertsch_at_[hidden])
Date: 2006-02-15 19:13:21


> > 4. For embedded environments that cannot use exceptions, I suggest using
> > boost::config to disable the throwing() behavior, and provide an
> > "isValid/isOpen" accessor function which would allow embedded developers to
> > interrogate the state of the object. When exceptions are turned on, this
> > function would always return true.
>
> The only problem I see to this behavior in my experience is that many
> times you develop a class for an embedded environment without exceptions
> (because of limitations) and you want to also test it in PC platforms or
> reuse use that code in another project and environment that do use
> exceptions. Since the code has not exception support (you don't program
> with exceptions AND error returns) you want the code to continue working
> in the new environment when the exceptions are thrown.
>
> That's why I would prefer overloading the constructors with an
> additional std::nothrow parameter for no-exception environments to
> disable exception and use is_valid() approach instead of defining a
> macro. This code would still work in new environments when the code is
> used somewhere else where exceptions are enabled.
>
> After the long debate about RAII I don't know if this solution would be
> accepted by boost members or only compile-time configuration is accepted.

This issue seems to be the only controversial point so far in this
review. :) I'd like to elicit some feedback on this so that I can
close up the review as quickly as possible after it ends tomorrow.

Ion is proposing a solution that solves many of the problems with a
two stage construction process. It is still possible to use the
constructors with std::no_throw and get an invalid state. I shouldn't
comment on the no-exceptions, embedded world that Ion is hoping to
placate with his strategy, but in the world where exceptions are
possible, it should be easy to tell that you're tripping over
something nasty when you pass std::no_throw into a constructor. It
seems to me that this should be good enough even if it's not ideal.

Because the topic generated some controversy, I'm hoping to get a few
people who complained about the two stage construction to comment on
the proposed solution before the review ends.

-Fred


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