Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-08-30 12:38:57


From: Beman Dawes <beman_at_[hidden]>
> In private email, Kevlin Henney points out that use of assert() in
> boost headers violates the ODR (one-definition rule).

How so? Could you please elaborate?

I recall some discussion of assert and the ODR some years ago, and some
suggestions, I think from Andy Koenig, on how to fix it, but it didn't
happen, and I know longer remember the details. I also recall that Mike
Vilot tried, and failed, to introduce a template-based alternative.

> ...
> Do others think that some such template base assertion approach is
> worth developing for boost? Has anyone else tried to develop
> assert() replacements?

There are four things I like about assert:

1) Being a macro, it can report the location in the source where it triggers.
2) Being a macro, it it easy to redefine it to throw, log, or whatever.
3) Being standard, it is always available.
4) Being standard, I have no qualms insisting that team members use it.

We can fix 3 and 4 some years out, and a Boost template might be a start
in that direction, but 1 and 2 are harder to pull off.

Regardless, I would hate to do anything that might discourage programmers
from using assert in C++ code.


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