#include <boost/mpl/apply.hpp>
template<class T, class R=void> struct enable_if_type { typedef R type; };
template<template<class,class> class T, class A, class B, class Enable=void>
struct select_proper_specialization
{
template<class X,class Y> struct apply
{
typedef T<Y,X> type;
};
};
template<template<class,class> class T, class A, class B>
struct select_proper_specialization<T,A,B, typename enable_if_type< T<A,B> >::type>
{
template<class X,class Y> struct apply
{
typedef T<X,Y> type;
};
};
template<class A,class B> struct foo;
template<> struct foo<int,float>
{
static void Test() { cout << "foo<A,B>" << endl; }
};
int main()
{
boost::mpl::apply< select_proper_specialization<foo,int,float>,int,float>::type::Test();
boost::mpl::apply< select_proper_specialization<foo,float,int>,float,int>::type::Test();
}