|
Boost : |
From: Rainer Deyke (root_at_[hidden])
Date: 2001-04-15 09:47:18
----- Original Message -----
From: "Jens Maurer" <Jens.Maurer_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, April 15, 2001 2:26 AM
Subject: Re: [boost] Boost.Assertion
> Rainer Deyke wrote:
> > It might be possible to provide a default handler and allow the user to
> > override it. Something like this:
> >
> > // In boost header:
> > template<class T> void assertion_handler(T) {}
> > void f(int *p)
> > {
> > if (!p) assertion_handler(1);
> > }
> >
> > // In user code:
> > void assertion_handler(int)
> > {
> > std::cerr << "Assertion failed." << std::endl;
> > }
>
>
> I believe that this does not work, because the function f() always calls
> the template function assertion_handler, because a declaration for the
> non-template overload is not visible at f().
In VC++6 SP5, at least, the overload is called. If this is not universal
behavior guaranteed by the Standard, then the declaration of
'assertion_handler(int)' would simply have to be placed above the boost
'#include's. The system requires that 'assertion_handler' is only called by
boost in header files, and that each user compilation module that
'#include's boost also includes the declaration for
'assertion_handler(int)', but that is IMO a fairly small price to pay.
-- Rainer Deyke (root_at_[hidden]) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk