#include <iostream>
#include <boost/mpl/or.hpp>
#include <boost/mpl/has_xxx.hpp>
using namespace std;
namespace details
{
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
template< class F
, template<class> class T = F::template result
> struct has_result_impl
{
typedef void type;
};
template<class F, class EnableIf = void> struct has_result_struct : boost::false_type {};
template<class F> struct has_result_struct<F,typename has_result_impl<F>::type> : boost::true_type {};
}
template<class F>
struct support_result_of_protocol
: boost::mpl::or_< details::has_result_type<F>
, details::has_result_struct<F>
>::type
{
};
struct nothing
{
};
struct has_a_result_type
{
typedef void result_type;
};
struct has_a_result
{
template<typename FArgs>
struct result;
template<typename T>
struct result<has_a_result(T)>
{
typedef T** type;
};
};
int main()
{
cout << support_result_of_protocol<nothing>::value << endl;
cout << support_result_of_protocol<has_a_result_type>::value << endl;
cout << support_result_of_protocol<has_a_result>::value << endl;
}