#include <boost/type_traits.hpp>
#include <boost/utility.hpp>
#include <iostream>
#include <ostream>

using namespace std;

struct Base1 {};
struct Derived1 : Base1 {};

struct Base2 {};
struct Derived2 : Base2 {};

template<typename T>
typename boost::enable_if< boost::is_base_of<Base1, T>, void >::type f(T* p)
{
    cout << "Base1" << endl;
}

template<typename T>
typename boost::enable_if< boost::is_base_of<Base2, T>, void >::type f(T* p)
{
    cout << "Base2" << endl;
}

int main()
{
    Derived1 d1;
    Derived2 d2;
    f(&d1);
    f(&d2);
}
