fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. #define GC_GENERATE_IS_HAS_TYPEDEF(_arg_type)\
  6. template<class T>\
  7. class is_has_typedef_##_arg_type{\
  8. struct detection{};\
  9. static detection\
  10. detect(...);\
  11. template<class Y>\
  12. static typename Y:: _arg_type\
  13. detect(const Y &);\
  14. public:\
  15. static constexpr bool value = !std::is_same<detection, decltype(detect(std::declval<T>()))>::value;\
  16. };\
  17. template<class T>\
  18. constexpr bool is_has_typedef_##_arg_type##_v = is_has_typedef_##_arg_type<T>::value;
  19.  
  20. GC_GENERATE_IS_HAS_TYPEDEF(value_type);
  21.  
  22. int main() {
  23. // your code goes here
  24. std::cout << is_has_typedef_value_type_v<std::vector<int>> << ' ' << is_has_typedef_value_type_v<int>;
  25. return 0;
  26. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
1 0