
Is there a type traits guru that can explain to me why the following doesn't work as I expect. It's got to be something very, very obvious but I can't see it. Thank you Robert Ramey #include <boost/static_assert.hpp> #include <boost/type_traits/is_base_and_derived.hpp> #include <boost/type_traits/remove_pointer.hpp> class Base1 { char a; }; class Base2 { int b; }; class Derived : public Base1, public Base2 { long c; }; void main(){ // this passes BOOST_STATIC_ASSERT((boost::is_base_and_derived< Base1, Derived >::value)); // this fails !? BOOST_STATIC_ASSERT((boost::is_base_and_derived< boost::remove_pointer<Base1 *>, boost::remove_pointer<Derived *> >::value)); }

Robert Ramey wrote:
Is there a type traits guru that can explain to me why the following doesn't work as I expect. It's got to be something very, very obvious but I can't see it.
remove_pointer<> is a metafunction. You need to get the result through the nested 'type'. remove_pointer<int*>::type x = 3; [snip]
// this fails !? BOOST_STATIC_ASSERT((boost::is_base_and_derived< boost::remove_pointer<Base1 *>::type, ^^^^^^ boost::remove_pointer<Derived *>::type ^^^^^^
::value)); }
-- Daniel Wallin

Robert Ramey wrote:
Is there a type traits guru that can explain to me why the following doesn't work as I expect. It's got to be something very, very obvious but I can't see it.
Thank you
Robert Ramey
You forgot about trailing '::type' BOOST_STATIC_ASSERT((boost::is_base_and_derived< boost::remove_pointer<Base1 *>::type, boost::remove_pointer<Derived *>::type
::value));
-- Alexander Nasonov Independent Developer and Consultant
participants (3)
-
Alexander Nasonov
-
Daniel Wallin
-
Robert Ramey