NamedType
NamedType copied to clipboard
cereal serialization functions
It took me a little while to figure out how to best serialize a NamedType using cereal (which is the BEST C++ serialization library I have found - if someone knows of a better one, please let me know). I am not sure of a good way to add this to the fluent codebase, so I thought I would post this issue in case this is helpful to others.
Cereal Serialization using external minimal serialization functions as described in Serialization Functions documentation.
namespace fluent {
template <typename Archive,
typename ValueType,
typename TagType,
template <typename>
class... Skills>
void load_minimal(
Archive&,
NamedType<ValueType, TagType, Skills...>& nobj,
typename NamedType<ValueType, TagType, Skills...>::UnderlyingType const& val)
{
using Ntype = NamedType<ValueType, TagType, Skills...>;
nobj = Ntype{val};
}
template <typename Archive,
typename ValueType,
typename TagType,
template <typename> class... Skills>
auto save_minimal(Archive&,
const NamedType<ValueType, TagType, Skills...>& nobj)
{
return nobj.get();
}
} // namespace fluent
Thanks for the reference!