Stealing from here, and assuming you fix your code so GetInt is const, we get:
HAS_MEM_FUNC(GetInt, has_GetInt);
template
struct bool_type
{
static const bool value = B;
};
typedef bool_type true_type;
typedef bool_type false_type;
namespace detail
{
template
int get_int(const T& pX, true_type)
{
return pX.GetInt();
}
template
int get_int(const T& pX, false_type)
{
return pX.m;
}
}
template
int get_int(const T& pX)
{
return detail::get_int(pX,
has_GetInt::value);
}
This is pretty awful design though. You should fix the problem rather than apply a patch.