Boost logo

Boost :

From: Frantz Maerten (frantz.maerten_at_[hidden])
Date: 2005-02-24 17:15:33

Hi all,

    While using boost::any with pointers, I realized the following
problem for polymorphic classes:

  class A {
    virtual ~A() {}
  } ;

  class B: public A {} ;

  int main() {
    boost::any b(new B) ;
    try {
      A* a = boost::any_cast<A*>(b) ;
    catch (const boost::bad_any_cast&) {/*failed*/}

Of course the following code failes, since rtti information is used for

I extended the boost::any concept, and incorporated a
boost::any_dynamic_cast (see attachment)
This extension uses boost::is_polymorphic and boost::remove_pointer,
and allows dynamic casting
if possible.

Does anyone need this features, and can it be incorporated (after some
regression tests) into the boost::any library?

Thanks for any comment about it.

--Frantz Maerten

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