fork(2) download
  1. #include <iostream>
  2.  
  3. namespace detail
  4. {
  5. template <typename T> struct helper;
  6.  
  7. template <typename T> struct helper<T*> { void operator() () const {std::cout << "pointer\n";} };
  8. template <typename T, std::size_t N> struct helper<T[N]> { void operator() ()const {std::cout << "array\n";} };
  9. }
  10.  
  11.  
  12. template <typename T>
  13. void f(const T& )
  14. {
  15. detail::helper<T>{}();
  16. }
  17.  
  18. int main() {
  19. const char a[] = "toto";
  20. const char*p = "toto";
  21.  
  22. f(a);
  23. f(p);
  24. f("toto");
  25.  
  26. }
  27.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
array
pointer
array