fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <type_traits>
  4.  
  5. template<typename, typename = void>
  6. struct is_incrementable : std::false_type {};
  7.  
  8. template<typename T>
  9. struct is_incrementable<T, std::void_t<decltype( ++std::declval<T&>() )>> : std::true_type {};
  10.  
  11. int main()
  12. {
  13. std::cout << is_incrementable<std::string>::value << std::endl;
  14. std::cout << is_incrementable<int>::value << std::endl;
  15. }
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
0
1