fork download
  1. #include <type_traits>
  2. #include <iostream>
  3.  
  4. template<class U>
  5. typename std::enable_if<
  6. std::is_array<U>::value,
  7. void
  8. >::type check(U const&) {
  9. std::cout << "is array type." << std::endl;
  10. }
  11.  
  12. template<class U>
  13. typename std::enable_if<
  14. !std::is_array<U>::value,
  15. void
  16. >::type check(U const&) {
  17. std::cout << "is not array type." << std::endl;
  18. }
  19.  
  20. int main() {
  21. int i;
  22. int a[5];
  23.  
  24. check(i);
  25. check(a);
  26. }
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
is not array type.
is array type.