Overloading output operator for arrays
问题 According to this answer, the correct way to overload output operator << for C-style arrays is this -: #include <iostream> using namespace std; template <size_t arrSize> std::ostream& operator<<( std::ostream& out, const char( &arr )[arrSize] ) { return out << static_cast<const char*>( arr ); // use the original version } // Print an array template<typename T1, size_t arrSize> std::ostream& operator <<( std::ostream& out, const T1( & arr )[arrSize] ) { out << "["; if ( arrSize ) { const char*