I already have SFINAE code that determines if a given member function exists and can accept an instance of a certain type.
I am trying to detect when there is a specific member function that accepts, since this is a non-LINK argument.
Code example
template<typename TYPE_T>
class HasSwapMemberImpl
{
template <typename CLASS_T>
static auto test_compatible_swap_function_exists(CLASS_T * p) -> decltype(p->swap(*static_cast<CLASS_T*>(nullptr)), boost::true_type());
template<typename>
static boost::false_type test_compatible_swap_function_exists(...);
public:
typedef decltype(test_compatible_swap_function_exists<TYPE_T>(nullptr)) type;
static const bool value = type::value;
};
template<typename ARG_T>
struct HasSwapMember : public HasSwapMemberImpl<ARG_T>::type { };
This works for a few dozen test cases that I wrote, so I don't need help here.
Instead, I try to detect a situation like this:
struct NonReferenceSwap
{
void swap(NonReferenceSwap) {}
};
struct ReferenceSwap
{
void swap(ReferenceSwap &) {}
};
I need a MetaHelperType metaprogramming assistant, such that MetaHelperType inherits from boost :: true_type, but MetaHelperType forces the compiler to fail with a message like "Swap functions must accept reference arguments!"
Or in other words:
MetaHelperType<ReferenceSwap>;
MetaHelperType<NoSwapFunction>;
MetaHelperType<NonReferenceSwap>;
? , foo.swap(bar), bar . C++, , , , - 2 .
Visual Studio 2010, ++ 11. , , , , .
? , ++ ? ++ 11, ++ 14, ++ 17?