fork download
  1. namespace X
  2. {
  3. template<typename T, unsigned int SIZE>
  4. bool IsArray (T (&a)[SIZE]) { return true; }
  5.  
  6. template<typename T>
  7. bool IsArray (T *p) { return false; }
  8. }
  9.  
  10. namespace Y
  11. {
  12. typedef char (&yes)[2];
  13.  
  14. template<typename T, unsigned int SIZE>
  15. yes IsArray (T (&a)[SIZE]);
  16.  
  17. template<typename T>
  18. char IsArray (T *p);
  19. }
  20.  
  21. using namespace X;
  22.  
  23. int main ()
  24. {
  25. const char *s2 = "hello";
  26. #if 1
  27. if(true == IsArray(s2))
  28. throw 0;
  29. #else
  30. if(sizeof(IsArray(s2)) == sizeof(yes))
  31. throw 0;
  32. #endif
  33. }
  34.  
Success #stdin #stdout 0.01s 2720KB
stdin
Standard input is empty
stdout
Standard output is empty