Ответ 1
Основная проблема заключалась в том, что:
std::is_same<bool, decltype(bar::is_baz)>::value == false
Тогда твой СФИНАЕ терпел неудачу всегда. Я has_is_baz
черту has_is_baz
и теперь она работает:
#include <iostream>
#include <utility>
#include <type_traits>
using namespace std;
template <class T>
class has_is_baz
{
template<class U, class = typename std::enable_if<!std::is_member_pointer<decltype(&U::is_baz)>::value>::type>
static std::true_type check(int);
template <class>
static std::false_type check(...);
public:
static constexpr bool value = decltype(check<T>(0))::value;
};
struct foo { };
struct bar
{
static constexpr bool is_baz = true;
};
struct not_static {
bool is_baz;
};
int main()
{
cout << has_is_baz<foo>::value << '\n';
cout << has_is_baz<bar>::value << '\n';
cout << has_is_baz<not_static>::value << '\n';
}
Изменить: я исправил черту типа. Как указывало @litb, он обнаруживал как статические, так и нестатические элементы.