Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2007-08-13 17:31:58


on Mon Aug 13 2007, "Gross, Steve" <SGross-AT-sjm.com> wrote:

> Is there a way to use the mpl to determine if an object can be converted
> to some parent / child class? That is, if A derives from B, can I say
> something like "mpl::is_convertible_to<A, B>::value" ?

See Boost.TypeTraits

   boost::is_base_and_Derived<B,A>::value

or more simply,

   boost::is_convertible<A*,B*>::value

MPL metafunctions are of course interoperable with the type traits.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net