// test7.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
using namespace std;
using namespace boost;
namespace
{
template<typename T> char checkSize(T*);
template<typename T> long checkSize(...);
}
template<typename FIRST, typename SECOND>
struct SameType
{
enum{value = sizeof(char) == sizeof(checkSize<FIRST>((SECOND*)0)) };
};
class IFoo
{
public:
virtual void bar() = 0;
};
class Foo: public IFoo
{
public:
virtual void bar(){ cout<<"bar()"<<endl; };
};
template<int>
class TypeSelect
{
public:
template<typename T>
TypeSelect(T& r){}
};
template<> class TypeSelect<true>
{
public:
template<typename T>
TypeSelect(T& r)
{
r.bar();
}
};
template<class T> void func( T& t )
{
(TypeSelect<SameType<IFoo, T>::value>(t));
}
int main()
{
Foo x;
int y;
func(x);
func(y);
}