Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-09-01 11:09:47


Beman Dawes wrote:
>
> Valentin Bonnard wrote:
>
> >Beman Dawes wrote:
> >
> >> Looking at 7.3.1.1 [namespace.unnamed], it seems the following
> >> technique allows the use of assert() in a header without
> introducing
> >> an ODR violation.
> >>
> >> namespace boost {
> >> namespace {
> >> template <class Derived, class Base>
> >> inline Derived polymorphic_cast(Base* x) {
> >> assert( dynamic_cast<Derived>(x) != 0 ); // detect logic
> >> error
> >> return static_cast<Derived>(x);
> >> }
> >> }
> >> }
> >>
> >> If this doesn't work,
> >
> >Technically this code is fine.
> >
> >But look at the problem from the user point of view:
> >it means that he can only use boost' casts in functions
> >with no or static linkage, or functions defined only
> >once.
>
> In other words, the problem has been reduced from the template always
> being an ODR violation if there were NDEBUG differences between
> translations units to only sometimes, depending on usage, being an
> ODR violation. Better, but not good enough.

That isn't clearly better:

- original problem: if NDEBUG gets a different value in
  different TUes, than ODR-problem

- new problem: even if NDEBUG gets the same value, any call
  to a boost function in inline or template functions ->
  ODR-problem

Notes:

- Here I assume that every TU include a boost header which
  uses assertions, and that every boost function uses them

- ODR-problem means that the behaviour is undefined because
  of the ODR

Conclusion:

  Since inline and template are very important in C++,
  it makes boost utterly useless for people:
  - who want well-defined behaviour, and
  - who don't want to check each boost for assertion
    usage

To me that's a terrible change. I can't call this
``better''. Until something better emerges, I urge
you to keep the existing code.

-- 
Valentin Bonnard

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