fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3.  
  4. struct Demo;
  5.  
  6. static void print(Demo*) { std::cout << "none\n"; }
  7. static void print(Demo const*) { std::cout << "const\n"; }
  8. static void print(Demo volatile*) { std::cout << "volatile\n"; }
  9. static void print(Demo const volatile*) { std::cout << "const volatile\n"; }
  10.  
  11. struct Demo {
  12. void none() { print(this); }
  13. void c() const { print(this); }
  14. void v() volatile { print(this); }
  15. void cv() const volatile { print(this); }
  16. };
  17.  
  18. int main() {
  19. Demo d;
  20. d.none();
  21. d.c();
  22. d.v();
  23. d.cv();
  24. }
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
none
const
volatile
const volatile