fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T, size_t N>
  5. ostream& operator<< (ostream& outA, T (& arr)[N]) {
  6. outA << arr[0];
  7. T (&next)[N-1] = reinterpret_cast<T(&)[N-1]>(arr[1]);
  8. outA << next;
  9. return outA;
  10. }
  11.  
  12. template<typename T>
  13. ostream& operator<< (ostream& outA, T (& arr)[1]) {
  14. outA << arr[0];
  15. return outA;
  16. }
  17.  
  18. int main() {
  19.  
  20. int a[] = {1, 2, 3, 4};
  21.  
  22. cout << a;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1234