#ifndef FILE__PRINT_HPP #define FILE__PRINT_HPP /* Changes ------- 2014-06-20: Eliminated the C++98/03 technique of printing arrays of arbitrary types with variable length (since g++ 4.8+ no longer supports these templates) and added two templates: one for single-dimensional arrays of doubles and another for two-dimensional arrays of doubles. */ #include #include template < size_t n > std::ostream & operator << ( std::ostream & o, double const ( & t )[ n ] ) { auto i = std::begin( t ); auto end = std::end( t ); o << '{'; if ( i != end ) { o << ' ' << *i; for ( ++i; i != end; ++i ) { o << ", " << *i; } o << ' '; } o << '}'; return o; } template < size_t row_size, size_t column_size > std::ostream & operator << ( std::ostream & o, double const ( & t )[ row_size ][ column_size ] ) { auto i = std::begin( t ); auto end = std::end( t ); o << '{'; if ( i != end ) { o << "\n\t" << *i; for ( ++i; i != end; ++i ) { o << ",\n\t" << *i; } o << '\n'; } o << '}'; return o; } template < typename T, typename A > std::ostream & operator << ( std::ostream & o, std::vector< T, A > const & v ) { auto i = std::begin( v ); auto end = std::end( v ); o << '{'; if ( i != end ) { o << ' ' << *i; for ( ++i; i != end; ++i ) { o << ", " << *i; } o << ' '; } o << '}'; return o; } #endif