mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
changed: handle pairs as tuples in eclmpiserializer
This commit is contained in:
parent
fdb2743ca9
commit
3c389d5ece
@ -89,12 +89,10 @@ public:
|
||||
{
|
||||
if constexpr (is_ptr<T>::value) {
|
||||
ptr(data);
|
||||
} else if constexpr (is_pair<T>::value) {
|
||||
pair(data);
|
||||
} else if constexpr (is_pair_or_tuple<T>::value) {
|
||||
tuple(data);
|
||||
} else if constexpr (is_variant<T>::value) {
|
||||
variant(data);
|
||||
} else if constexpr (is_tuple<T>::value) {
|
||||
tuple(data);
|
||||
} else if constexpr (is_optional<T>::value) {
|
||||
optional(data);
|
||||
} else if constexpr (is_vector<T>::value) {
|
||||
@ -126,8 +124,8 @@ public:
|
||||
auto handle = [&](auto& d)
|
||||
{
|
||||
for (auto& it : d) {
|
||||
if constexpr (is_pair<T>::value)
|
||||
pair(it);
|
||||
if constexpr (is_pair_or_tuple<T>::value)
|
||||
tuple(it);
|
||||
else if constexpr (is_ptr<T>::value)
|
||||
ptr(it);
|
||||
else if constexpr (is_vector<T>::value)
|
||||
@ -188,8 +186,8 @@ public:
|
||||
|
||||
auto handle = [&](auto& d) {
|
||||
for (auto& it : d) {
|
||||
if constexpr (is_pair<T>::value)
|
||||
pair(it);
|
||||
if constexpr (is_pair_or_tuple<T>::value)
|
||||
tuple(it);
|
||||
else if constexpr (is_ptr<T>::value)
|
||||
ptr(it);
|
||||
else if constexpr (has_serializeOp<T>::value)
|
||||
@ -268,22 +266,10 @@ public:
|
||||
|
||||
//! \brief Handler for std::tuple.
|
||||
//! \param data The tuple to (de-)serialize
|
||||
template<class... Args>
|
||||
void tuple(const std::tuple<Args...>& data)
|
||||
template<class Tuple>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//! \brief Handler for maps.
|
||||
@ -311,8 +297,8 @@ public:
|
||||
|
||||
auto keyHandle = [&](auto& d)
|
||||
{
|
||||
if constexpr (is_pair<Key>::value)
|
||||
pair(d);
|
||||
if constexpr (is_pair_or_tuple<Key>::value)
|
||||
tuple(d);
|
||||
else if constexpr (has_serializeOp<Key>::value)
|
||||
d.serializeOp(*this);
|
||||
else
|
||||
@ -545,17 +531,6 @@ protected:
|
||||
UNPACK //!< Performing de-serialization
|
||||
};
|
||||
|
||||
//! \brief Predicate for detecting pairs.
|
||||
template<class T>
|
||||
struct is_pair {
|
||||
constexpr static bool value = false;
|
||||
};
|
||||
|
||||
template<class T1, class T2>
|
||||
struct is_pair<std::pair<T1,T2>> {
|
||||
constexpr static bool value = true;
|
||||
};
|
||||
|
||||
//! \brief Predicate for detecting vectors.
|
||||
template<class T>
|
||||
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<class T>
|
||||
struct is_tuple {
|
||||
struct is_pair_or_tuple {
|
||||
constexpr static bool value = false;
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
struct is_tuple<std::tuple<Ts...>> {
|
||||
struct is_pair_or_tuple<std::tuple<Ts...>> {
|
||||
constexpr static bool value = true;
|
||||
};
|
||||
|
||||
template<class T1, class T2>
|
||||
struct is_pair_or_tuple<std::pair<T1,T2>> {
|
||||
constexpr static bool value = true;
|
||||
};
|
||||
|
||||
@ -674,21 +654,6 @@ protected:
|
||||
T, std::void_t<decltype(std::declval<T>().serializeOp(std::declval<EclMpiSerializer&>()))>
|
||||
> : public std::true_type {};
|
||||
|
||||
//! \brief Handler for pairs.
|
||||
template<class T1, class T2>
|
||||
void pair(const std::pair<T1,T2>& data)
|
||||
{
|
||||
if constexpr (has_serializeOp<T1>::value)
|
||||
const_cast<T1&>(data.first).serializeOp(*this);
|
||||
else
|
||||
(*this)(data.first);
|
||||
|
||||
if constexpr (has_serializeOp<T2>::value)
|
||||
const_cast<T2&>(data.second).serializeOp(*this);
|
||||
else
|
||||
(*this)(data.second);
|
||||
}
|
||||
|
||||
//! \brief Handler for smart pointers.
|
||||
template<class PtrType>
|
||||
void ptr(const PtrType& data)
|
||||
|
Loading…
Reference in New Issue
Block a user