fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4.  
  5. struct A {
  6. using my_tag = int; // changed to int
  7. };
  8.  
  9. struct B {};
  10.  
  11.  
  12. // same as your enable_if_type
  13. template <typename...>
  14. using void_t = void;
  15.  
  16.  
  17. template<class T, class Enable = void>
  18. struct has_my_tag : std::false_type {};
  19.  
  20. template<class T> // specialization will not match with int
  21. struct has_my_tag<T, typename T::my_tag> : std::true_type
  22. {};
  23.  
  24.  
  25. int main() {
  26. std::cout << has_my_tag<A>::value << std::endl;
  27. std::cout << has_my_tag<B>::value << std::endl;
  28. return 0;
  29. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
0
0