#include <iostream>
#include <type_traits>

template<typename T>
struct has_size_method
{
private:
	typedef std::true_type yes;
	typedef std::false_type no;

	template<typename U, int (U::*f)() const> struct SFINAE{};
	template<typename U, std::size_t (U::*f)() const> struct SFINAE<U,f>{};


	template<class C> static yes test(SFINAE<C,&C::size>*);
	template<class C> static no test(...);

public:
	static constexpr bool value = std::is_same<yes,decltype(test<T>(nullptr))>::value;
};

struct x
{
	int size() const { return 42; }
};

struct y : x {};

int main()
{
	std::cout << has_size_method<x>::value << std::endl;
	std::cout << has_size_method<y>::value << std::endl;
}
