From 059efcd2603b25c7d0d120b61fd8ef0ab458a00c Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 22 Oct 2021 08:23:59 +0200 Subject: [PATCH] Add serializer support for std::array --- ebos/eclmpiserializer.hh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ebos/eclmpiserializer.hh b/ebos/eclmpiserializer.hh index e68877a2b..e821b717a 100644 --- a/ebos/eclmpiserializer.hh +++ b/ebos/eclmpiserializer.hh @@ -103,6 +103,36 @@ public: } } + template + void array(Array& data) + { + using T = typename Array::value_type; + + auto handle = [&](auto& d) { + for (auto& it : d) { + if constexpr (is_pair::value) + pair(it); + else if constexpr (is_ptr::value) + ptr(it); + else if constexpr (!complexType) + (*this)(it); + else + it.serializeOp(*this); + } + }; + + if (m_op == Operation::PACKSIZE) { + m_packSize += Mpi::packSize(data.size(), m_comm); + handle(data); + } else if (m_op == Operation::PACK) { + Mpi::pack(data.size(), m_buffer, m_position, m_comm); + handle(data); + } else if (m_op == Operation::UNPACK) { + size_t size; + Mpi::unpack(size, m_buffer, m_position, m_comm); + handle(data); + } + } //! \brief Handler for std::variant<> with four types