Boost logo

Boost :

From: Stewart, Robert (stewart_at_[hidden])
Date: 2001-11-12 15:16:05

> From: Peter Dimov [mailto:pdimov_at_[hidden]]
> You have three options of wiring up assertions to be reported
> to the end
> user.
> 1. Leave BOOST_ASSERT to assert(). ('return true' from boost_error or
> use -DBOOST_ASSERT=assert.)
> 2. Provide your own BOOST_ASSERT.
> 3. Report the error to the user from boost_error.
> (1) will automatically take advantage of __func__, (2) is
> fine as well. It's
> only (3) that doesn't receive the function name.
> The scenarios that I had in mind for overriding boost_error
> were throwing an
> exception (presumably to be handled by a higher level
> component), logging
> the error to a file, or performing cleanup before
> assert()ing. None of these
> really needs the function name, although it can't hurt.

Why not use a set_terminate_handler-like interface for setting the
boost_error-like function? If that works for the standard, why not for
Boost? I suppose that you're worried that the function pointer might not be
initialized to the address of boost_error when called from some static
object's initialization. If you initialize the pointer to zero, and use
that as a special case that calls boost_error, then there should be no
problem (other than that the library user may have wanted to have their own
replacement called at a point when their "set handler" logic hasn't run.

> If we do add a 'const char * func' parameter to boost_error,
> the problems
> are (1) how do we detect __func__ (#ifdef __func__ is no
> good) and (2) what
> do we pass for 'func' when __func__ is not supported.

config.hpp could define "__func__" to be a null pointer for compilers that
don't support __func__. Then, boost_error() must be written to expect a
null pointer for the function name parameter.

Susquehanna International Group, LLP

IMPORTANT: The information contained in this email and/or its attachments is
confidential. If you are not the intended recipient, please notify the
sender immediately by reply and immediately delete this message and all its
attachments. Any review, use, reproduction, disclosure or dissemination of
this message or any attachment by an unintended recipient is strictly
prohibited. Neither this message nor any attachment is intended as or
should be construed as an offer, solicitation or recommendation to buy or
sell any security or other financial instrument. Neither the sender, his or
her employer nor any of their respective affiliates makes any warranties as
to the completeness or accuracy of any of the information contained herein
or that this message or any of its attachments is free of viruses.

Boost list run by bdawes at, gregod at, cpdaniel at, john at