language: C++ 4.7.2 (gcc-4.7.2)
date: 190 days 4 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#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);
}