added: map predicate

use it to allow for serializing nested maps
This commit is contained in:
Arne Morten Kvarving 2022-09-06 09:35:12 +02:00
parent 14070fdfcb
commit 2d2f25b778

View File

@ -246,6 +246,8 @@ public:
this->vector(d);
else if constexpr (is_ptr<Data>::value)
this->ptr(d);
else if constexpr (is_map<Data>::value)
this->map(d);
else if constexpr (has_serializeOp<Data>::value)
d.serializeOp(*this);
else
@ -464,6 +466,22 @@ protected:
constexpr static bool value = true;
};
//! \brief Predicate for maps
template<class T>
struct is_map {
constexpr static bool value = false;
};
template<class Key, class T, class Compare, class Allocator>
struct is_map<std::map<Key,T,Compare,Allocator>> {
constexpr static bool value = true;
};
template<class Key, class T, class Hash, class KeyEqual, class Allocator>
struct is_map<std::unordered_map<Key,T,Hash,KeyEqual,Allocator>> {
constexpr static bool value = true;
};
//! Detect existence of \c serializeOp member function
//!
//! Base case (no \c serializeOp member function)