fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T>
  5. struct IsPointer
  6. {
  7. enum{ value= false };
  8. };
  9.  
  10. template<typename T>
  11. struct IsPointer<T*>
  12. {
  13. enum{ value= true };
  14. };
  15.  
  16. template <typename T>
  17. bool isPointer(T notused)
  18. {
  19. return IsPointer<T>::value;
  20. }
  21.  
  22. int main()
  23. {
  24. int v= 10;
  25. int *p = new int;
  26.  
  27. std::cout << std::boolalpha;
  28. std::cout << isPointer(v) <<std::endl;
  29. std::cout << isPointer(p) <<std::endl;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
false
true