mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-12 09:21:56 -06:00
Merge pull request #4089 from akva2/serializer_handle_optional
Optionals are handled in serializer
This commit is contained in:
commit
0e49eb3a52
@ -442,8 +442,8 @@ protected:
|
||||
constexpr static bool value = false;
|
||||
};
|
||||
|
||||
template<class T1>
|
||||
struct is_vector<std::vector<T1>> {
|
||||
template<class T1, class Allocator>
|
||||
struct is_vector<std::vector<T1,Allocator>> {
|
||||
constexpr static bool value = true;
|
||||
};
|
||||
|
||||
|
@ -68,17 +68,6 @@ std::size_t packSize(const std::pair<T1,T2>& data, Opm::Parallel::MPIComm comm)
|
||||
return packSize(data.first, comm) + packSize(data.second, comm);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::size_t packSize(const std::optional<T>& data, Opm::Parallel::MPIComm comm)
|
||||
{
|
||||
bool has_value = data.has_value();
|
||||
std::size_t pack_size = packSize(has_value, comm);
|
||||
if (has_value)
|
||||
pack_size += packSize(*data, comm);
|
||||
return pack_size;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class A>
|
||||
std::size_t packSize(const std::vector<T,A>& data, Opm::Parallel::MPIComm comm)
|
||||
{
|
||||
@ -275,17 +264,6 @@ void pack(const std::pair<T1,T2>& data, std::vector<char>& buffer, int& position
|
||||
pack(data.second, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void pack(const std::optional<T>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm)
|
||||
{
|
||||
bool has_value = data.has_value();
|
||||
pack(has_value, buffer, position, comm);
|
||||
if (has_value)
|
||||
pack(*data, buffer, position, comm);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class A>
|
||||
void pack(const std::vector<T, A>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm)
|
||||
@ -473,21 +451,6 @@ void unpack(std::pair<T1,T2>& data, std::vector<char>& buffer, int& position,
|
||||
unpack(data.second, buffer, position, comm);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void unpack(std::optional<T>&data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm)
|
||||
{
|
||||
bool has_value;
|
||||
unpack(has_value, buffer, position, comm);
|
||||
if (has_value) {
|
||||
T val;
|
||||
unpack(val, buffer, position, comm);
|
||||
data = std::optional<T>(val);
|
||||
} else
|
||||
data.reset();
|
||||
}
|
||||
|
||||
|
||||
template<class T, class A>
|
||||
void unpack(std::vector<T,A>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm)
|
||||
@ -714,10 +677,7 @@ INSTANTIATE_PACK(std::array<int,3>)
|
||||
INSTANTIATE_PACK(std::array<double,4>)
|
||||
INSTANTIATE_PACK(std::array<double,5>)
|
||||
INSTANTIATE_PACK(std::map<std::pair<int,int>,std::pair<bool,double>>)
|
||||
INSTANTIATE_PACK(std::optional<double>)
|
||||
INSTANTIATE_PACK(std::optional<std::string>)
|
||||
INSTANTIATE_PACK(std::pair<double, double>)
|
||||
INSTANTIATE_PACK(std::optional<std::pair<double,double>>)
|
||||
INSTANTIATE_PACK(std::map<std::string,std::vector<int>>)
|
||||
INSTANTIATE_PACK(std::map<std::string,std::map<std::pair<int,int>,int>>)
|
||||
INSTANTIATE_PACK(std::map<std::string,int>)
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include <bitset>
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
@ -83,9 +82,6 @@ std::size_t packSize(const T& data, Opm::Parallel::MPIComm comm)
|
||||
template<class T1, class T2>
|
||||
std::size_t packSize(const std::pair<T1,T2>& data, Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T>
|
||||
std::size_t packSize(const std::optional<T>& data, Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T, class A>
|
||||
std::size_t packSize(const std::vector<T,A>& data, Opm::Parallel::MPIComm comm);
|
||||
|
||||
@ -164,10 +160,6 @@ template<class T1, class T2>
|
||||
void pack(const std::pair<T1,T2>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T>
|
||||
void pack(const std::optional<T>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T, class A>
|
||||
void pack(const std::vector<T,A>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
@ -257,10 +249,6 @@ template<class T1, class T2>
|
||||
void unpack(std::pair<T1,T2>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T>
|
||||
void unpack(std::optional<T>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
||||
template<class T, class A>
|
||||
void unpack(std::vector<T,A>& data, std::vector<char>& buffer, int& position,
|
||||
Opm::Parallel::MPIComm comm);
|
||||
|
Loading…
Reference in New Issue
Block a user