Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-10 18:40:12


One thing I want which I don't think is in the proposal is the ability to
determine at compile-time whether or not a type is polymorphic.

I am building a runtime representation of the inheritance hierarchy for type
conversion in Boost.Python. For polymorphic types, I need to generate
downcasts. As it stands, the interface is clumsy because the user has to
tell the library whether a given base class is polymorphic.

If a type X is not polymorphic, it is illegal to even write

    dynamic_cast<Y*>(&a)

where typeid(a)==typeid(X), unless Y is a base class of X.

Since it seems highly unlikely that we'll get the compile-time "tell me
whether this expression would be an error" operator, we ought to be
aggressive about pursuing things that help us avoid making errors in the
first place ;-)

===================================================
  David Abrahams, C++ library designer for hire
 resume: http://users.rcn.com/abrahams/resume.html

        C++ Booster (http://www.boost.org)
          email: david.abrahams_at_[hidden]
===================================================


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