fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T> bool isConst(T& x)
  5. {
  6. return false;
  7. }
  8.  
  9. template <typename T> bool isConst(T const& x)
  10. {
  11. return true;
  12. }
  13.  
  14. int main()
  15. {
  16. int a = 1;
  17. const int& x = a;
  18. std::cout << std::boolalpha;
  19. std::cout << isConst(x) << std::endl;
  20. std::cout << std::is_const<const int&>::value << std::endl;
  21. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
true
false