diff --git a/ebos/eclmpiserializer.hh b/ebos/eclmpiserializer.hh index 7e4c358da..57ce34722 100644 --- a/ebos/eclmpiserializer.hh +++ b/ebos/eclmpiserializer.hh @@ -89,12 +89,10 @@ public: { if constexpr (is_ptr::value) { ptr(data); - } else if constexpr (is_pair::value) { - pair(data); + } else if constexpr (is_pair_or_tuple::value) { + tuple(data); } else if constexpr (is_variant::value) { variant(data); - } else if constexpr (is_tuple::value) { - tuple(data); } else if constexpr (is_optional::value) { optional(data); } else if constexpr (is_vector::value) { @@ -126,8 +124,8 @@ public: auto handle = [&](auto& d) { for (auto& it : d) { - if constexpr (is_pair::value) - pair(it); + if constexpr (is_pair_or_tuple::value) + tuple(it); else if constexpr (is_ptr::value) ptr(it); else if constexpr (is_vector::value) @@ -188,8 +186,8 @@ public: auto handle = [&](auto& d) { for (auto& it : d) { - if constexpr (is_pair::value) - pair(it); + if constexpr (is_pair_or_tuple::value) + tuple(it); else if constexpr (is_ptr::value) ptr(it); else if constexpr (has_serializeOp::value) @@ -268,22 +266,10 @@ public: //! \brief Handler for std::tuple. //! \param data The tuple to (de-)serialize - template - void tuple(const std::tuple& data) + template + void tuple(const Tuple& data) { - if (m_op == Operation::PACKSIZE) { - m_op = Operation::PACKSIZE; - m_packSize = 0; - tuple_call(data); - } else if (m_op == Operation::PACK) { - m_position = 0; - m_buffer.resize(m_packSize); - tuple_call(data); - } else if (m_op == Operation::UNPACK) { - m_position = 0; - m_op = Operation::UNPACK; - tuple_call(data); - } + tuple_call(data); } //! \brief Handler for maps. @@ -311,8 +297,8 @@ public: auto keyHandle = [&](auto& d) { - if constexpr (is_pair::value) - pair(d); + if constexpr (is_pair_or_tuple::value) + tuple(d); else if constexpr (has_serializeOp::value) d.serializeOp(*this); else @@ -545,17 +531,6 @@ protected: UNPACK //!< Performing de-serialization }; - //! \brief Predicate for detecting pairs. - template - struct is_pair { - constexpr static bool value = false; - }; - - template - struct is_pair> { - constexpr static bool value = true; - }; - //! \brief Predicate for detecting vectors. template struct is_vector { @@ -578,14 +553,19 @@ protected: constexpr static bool value = true; }; - //! \brief Predicate for detecting tuples. + //! \brief Predicate for detecting pairs and tuples. template - struct is_tuple { + struct is_pair_or_tuple { constexpr static bool value = false; }; template - struct is_tuple> { + struct is_pair_or_tuple> { + constexpr static bool value = true; + }; + + template + struct is_pair_or_tuple> { constexpr static bool value = true; }; @@ -674,21 +654,6 @@ protected: T, std::void_t().serializeOp(std::declval()))> > : public std::true_type {}; - //! \brief Handler for pairs. - template - void pair(const std::pair& data) - { - if constexpr (has_serializeOp::value) - const_cast(data.first).serializeOp(*this); - else - (*this)(data.first); - - if constexpr (has_serializeOp::value) - const_cast(data.second).serializeOp(*this); - else - (*this)(data.second); - } - //! \brief Handler for smart pointers. template void ptr(const PtrType& data)