From efd3d83b6039c87e76bf596e984cb7966317fa0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org> Date: Tue, 14 Jun 2016 21:25:23 +0200 Subject: [PATCH] Implement writeBinary and readBinary using forEach This uses the new HybridAlgorithm::forEach() instead of the old one in writeBinary() and makes readBinary() aware of heterogeneous containers. --- dune/solvers/common/genericvectortools.hh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dune/solvers/common/genericvectortools.hh b/dune/solvers/common/genericvectortools.hh index d666e5aa..c0a9bc0b 100644 --- a/dune/solvers/common/genericvectortools.hh +++ b/dune/solvers/common/genericvectortools.hh @@ -32,8 +32,9 @@ struct GenericVector template <class VectorType> static void writeBinary(std::ostream& s, const VectorType& v) { - Dune::Solvers::integralRangeFor<std::size_t>(Dune::Indices::_0, Dune::Solvers::hybridSize(v), [&](auto&& i) { - GenericVector::writeBinary(s, v[i]); + namespace HA = Dune::Solvers::HybridAlgorithm; + HA::forEach(v, [&](auto&& vi) { + GenericVector::writeBinary(s, vi); }); } @@ -51,10 +52,10 @@ struct GenericVector template <class VectorType> static void readBinary(std::istream& s, VectorType& v) { - typename VectorType::iterator it = v.begin(); - typename VectorType::iterator end = v.end(); - for(; it!=end; ++it) - GenericVector::readBinary(s, *it); + namespace HA = Dune::Solvers::HybridAlgorithm; + HA::forEach(v, [&](auto&& vi) { + GenericVector::readBinary(s, vi); + }); } template <class field_type, int n> -- GitLab