From: Wolfgang Bangerth Date: Tue, 5 May 2020 14:42:25 +0000 (-0600) Subject: Implement operator<<(ostream,Vector) in a better way. X-Git-Tag: v9.2.0-rc1~117^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3682ce6fd7f2eb1526ad83748212d43875ad21b8;p=dealii.git Implement operator<<(ostream,Vector) in a better way. --- diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index a82e125c3d..3893218ab1 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -1369,10 +1369,18 @@ swap(Vector &u, Vector &v) */ template inline std::ostream & -operator<<(std::ostream &os, const Vector &v) +operator<<(std::ostream &out, const Vector &v) { - v.print(os); - return os; + Assert(v.size() != 0, ExcEmptyObject()); + AssertThrow(out, ExcIO()); + + for (typename Vector::size_type i = 0; i < v.size() - 1; ++i) + out << v(i) << ' '; + out << v(v.size() - 1); + + AssertThrow(out, ExcIO()); + + return out; } /*@}*/