diff --git a/ebos/eclmpiserializer.hh b/ebos/eclmpiserializer.hh index d3d09b80a..1347cd2b5 100644 --- a/ebos/eclmpiserializer.hh +++ b/ebos/eclmpiserializer.hh @@ -121,7 +121,7 @@ public: template void vector(std::vector& data) { - auto handle = [&](auto& d) + [[maybe_unused]] auto handle = [&](auto& d) { for (auto& it : d) { if constexpr (is_pair_or_tuple::value) @@ -139,15 +139,24 @@ public: if (m_op == Operation::PACKSIZE) { m_packSize += Mpi::Packer::packSize(data.size(), m_comm); - handle(data); + if constexpr (std::is_pod_v) + m_packSize += Mpi::Packer::packSize(data.data(), data.size(), m_comm); + else + handle(data); } else if (m_op == Operation::PACK) { - Mpi::packer::pack(data.size(), m_buffer, m_position, m_comm); - handle(data); + Mpi::Packer::pack(data.size(), m_buffer, m_position, m_comm); + if constexpr (std::is_pod_v) + Mpi::Packer::pack(data.data(), data.size(), m_buffer, m_position, m_comm); + else + handle(data); } else if (m_op == Operation::UNPACK) { size_t size; Mpi::Packer::unpack(size, m_buffer, m_position, m_comm); data.resize(size); - handle(data); + if constexpr (std::is_pod_v) + Mpi::Packer::unpack(data.data(), size, m_buffer, m_position, m_comm); + else + handle(data); } } @@ -184,7 +193,7 @@ public: { using T = typename Array::value_type; - auto handle = [&](auto& d) { + [[maybe_unused]] auto handle = [&](auto& d) { for (auto& it : d) { if constexpr (is_pair_or_tuple::value) tuple(it); @@ -198,15 +207,20 @@ public: }; if (m_op == Operation::PACKSIZE) { - m_packSize += Mpi::Packer::packSize(data.size(), m_comm); - handle(data); + if constexpr (std::is_pod_v) + m_packSize += Mpi::Packer::packSize(data.data(), data.size(), m_comm); + else + handle(data); } else if (m_op == Operation::PACK) { - Mpi::Packer::pack(data.size(), m_buffer, m_position, m_comm); - handle(data); + if constexpr (std::is_pod_v) + Mpi::Packer::pack(data.data(), data.size(), m_buffer, m_position, m_comm); + else + handle(data); } else if (m_op == Operation::UNPACK) { - size_t size; - Mpi::Packer::unpack(size, m_buffer, m_position, m_comm); - handle(data); + if constexpr (std::is_pod_v) + Mpi::Packer::unpack(data.data(), data.size(), m_buffer, m_position, m_comm); + else + handle(data); } }