Skip to content

Instantly share code, notes, and snippets.

@geneotech
Created February 1, 2018 14:20
Show Gist options
  • Save geneotech/a48a977540d95c3d1db765e639de9720 to your computer and use it in GitHub Desktop.
Save geneotech/a48a977540d95c3d1db765e639de9720 to your computer and use it in GitHub Desktop.
#include <type_traits>
#include <iostream>
template <class A, class = void>
struct has_member : std::false_type {};
template <class A>
struct has_member<A, decltype(A::member, void())> : std::true_type {};
struct AA { static constexpr bool member = true; };
struct BB {};
int main() {
std::cout << has_member<AA>::value << std::endl;
std::cout << has_member<BB>::value << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment