Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-09-01 07:40:34

Looking at [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
        return static_cast<Derived>(x);

If this doesn't work, please break it to me gently. I already have a
headache from thinking about assertions and the ODR.

It also does nothing to address Kevlin's other concerns regarding use
of assert in the cast functions. But that is a somewhat different


Boost list run by bdawes at, gregod at, cpdaniel at, john at