Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cereal serialization functions #49

Open
pwm1234 opened this issue Aug 26, 2020 · 1 comment
Open

cereal serialization functions #49

pwm1234 opened this issue Aug 26, 2020 · 1 comment

Comments

@pwm1234
Copy link

pwm1234 commented Aug 26, 2020

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
@joboccara
Copy link
Owner

Thanks for the reference!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants