From 3682ce6fd7f2eb1526ad83748212d43875ad21b8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 5 May 2020 08:42:25 -0600 Subject: [PATCH] Implement operator<<(ostream,Vector) in a better way. --- include/deal.II/lac/vector.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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; } /*@}*/ -- 2.39.5