Actually you can use only one Handler class and some templated function overloads:
template<class Base>
class Hanlder
{
template<class Derived>
void do_it(T const& t, typename boost::enable_if< boost::is_base_of<Base, T> >::type*=0)
{
//do smth.
}
template<class Derived>
void do_it(boost::shared_ptr<T> t, typename boost::enable_if< boost::is_base_of<Base, T> >::type*=0)
{
//do smth.
}
....
};Thanks Martin and Ovanes,I think you have put me on the right track there. Much appreciated.James
Just a quick addendum to this. I tried out a combination of the two - using a BOOST_STATIC_ASSERT((boost::is_base_of<Base, T> >::value)) inside the do_it function described above, and found what I thought was odd behaviour with is_base_of.
The following excerpt shows the behaviour
class A {};
class B : public A {};
typedef A C;
BOOST_STATIC_ASSERT((boost::is_base_of<A,B> >::value)) // this passes
BOOST_STATIC_ASSERT((boost::is_base_of<A,C> >::value)) // this fails
I would expect both to pass, as is_base_of should return true when both parameters are the same, and I thought that typedef did make classes the same/equivalent
http://www.boost.org/doc/html/boost_typetraits/reference.html#boost_typetraits.is_base_of
Is there something I am missing about typedef? Or is boost::is_base_of unable to handles the aliasing?
James