0%

tttt

1
2
3
4
5
6
7
8
template <typename T>
struct has_member_foo
{
template <typename U, void (U::*)()> struct SFINAE {};
template <typename U> static char check(SFINAE<U, &U::foo>*);
template <typename U> static int check(...);
static const bool value = sizeof(check<T>(0)) == sizeof(char);
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <utility>
template <typename T>
struct has_member_foo11
{
private:
template<typename U> static auto check(int) ->
decltype(std::declval<U>().foo(), std::true_type());

template<typename U> static std::false_type check(...);

public:
enum {
value = std::is_same<decltype(check<T>(0)),std::true_type>::value
};
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
template <typename T, typename ...Args>
struct has_member_foo11
{
private:
template<typename U> static auto check(int) ->
decltype(std::declval<U>().foo(std::declval<Args>()...), std::true_type());

template<typename U> static std::false_type check(...);

public:
enum {
value = std::is_same<decltype(check<T>(0)),std::true_type>::value
};
};