Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-12-08 19:51:04


At 11:43 AM 12/7/99 +0100, Csaba Szepesvari wrote:

>Attached is the ctassert solution I am using in my projects; it is
slightly
>different from the codes that appeared here.
>
>Motivation (see also the documentation):
>
>(R1) A minimal requirement of a good compile time assertion facility
is to give
>an error message *at the line* where the assertion fails.
>(R2) Another requirement is that the facility should be usable in
both
>declarations and implementations in the same way.
>(R3) The last requirement is that no real code should be generated
and no
>storage should be used.
>(R4) No macros.
>(R5) The namespaces should be polluted in a minimal way.
>
>All the above requirements :-)
>-- except --
>the last two are supported by this implementation :-(
>
>Unfortunately, in order to ensure R1 you need macros. In order to
support R2 and
>R3 you need class declarations. Unfortunately, this means some
pollution of the
>active scope. It also follows that the macro needs two parameters:
the first
>being the constant boolean expression to be evaluated and the second
being the
>"name of the check". These names should be different in the same
scope for
>repeated usage of this macro - in this respect the code could be
improved
>somewhat e.g. using __line__, etc.
>
>Comments are appreciated.

I doubt you will get much support for any solution that requires
macros.

Macro scope problems are just too serious.

Furthermore, compilers are getting better at reporting errors from
templates; many now show at least a portion of the template call
stack, allowing easier identification of the underlying problem code.
This takes away one of the prime motivations for using a macro.

--Beman


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