Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-09-01 08:28:12


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.

Your code is correct, but puts pressure on the user.
Boost should try to simplify (when possible) the
user's life.

-- 
Valentin Bonnard

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