fork(1) download
  1. #include <iostream>
  2. #include <type_traits>
  3. #include <string>
  4.  
  5. struct has_member_type_impl
  6. {
  7. template <typename T> static std::true_type snifae(typename T::type *);
  8. template <typename...> static std::false_type snifae(...);
  9. };
  10.  
  11. template <typename T>
  12. struct has_member_type : decltype(has_member_type_impl::snifae<T>(nullptr)) {};
  13.  
  14. struct test { using type = void; };
  15.  
  16. int main() {
  17. std::cout << has_member_type<int>::value << std::endl;
  18. std::cout << has_member_type<test>::value << std::endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
0
1