Hi James,
the easiest way is something like the following:
#include
#include BOOST_STATIC_ASSERT (boost::is_base_of
::value); Hope this helps,
Martin
Thanks Martin - I knew I had seen it somewhere.
That covers the first point, but I've just realised I need to be a bit cleverer. The incoming type can either be the type itself or a pointer to the type, or a boost::shared_ptr to the type, and the type must be derived as the original question. Depending on which it is I need to do slightly different things, so I need to, effectively, conditionally compile a bit of code depending on the results of the tests, or assert if the type (after getting rid of the pointer/shared point bit) isn't derived from my base class.
Basically I'm iterating through a vector of the incoming type and calling a function in the type stored. That function comes from the base class, but in order to be really generic I need to handle the shared_ptr and pointer cases.
I think I need mpl for that, but I only get to chapter three of the book before my head starts to hurt. Any ideas/hints/places I can look?
I'm not sure if you really need mpl to do this. To me it looks as if you
need one template
and multiple partial specialization, something like the following:
template<typename T>
class Handler
{
public:
void doIt (T val)
{
.... // default implementation
}
};
template<typename T>
class Handler