Skip to content

Commit

Permalink
Merge pull request arximboldi#153 from cyrilRomain/master
Browse files Browse the repository at this point in the history
Support monostate variant serialization
  • Loading branch information
arximboldi authored Jun 28, 2022
2 parents 56125da + bc0f78e commit 6294fae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lager/extra/cereal/variant_with_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ inline void CEREAL_LOAD_FUNCTION_NAME(Archive& ar, std::variant<Ts...>& variant)
detail::load_variant<0, variant_t, Ts...>(ar, target, variant);
}

//! Serializing a std::monostate
template <class Archive>
void CEREAL_SERIALIZE_FUNCTION_NAME( Archive &, std::monostate const & ) {}

} // namespace cereal
22 changes: 22 additions & 0 deletions test/cereal/variant_with_name.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// lager - library for functional interactive c++ programs
// Copyright (C) 2017 Juan Pedro Bolivar Puente
//
// This file is part of lager.
//
// lager is free software: you can redistribute it and/or modify
// it under the terms of the MIT License, as detailed in the LICENSE
// file located at the root of this source code distribution,
// or here: <https://github.com/arximboldi/lager/blob/master/LICENSE>
//

#include "cerealize.hpp"
#include <catch.hpp>
#include <lager/extra/cereal/variant_with_name.hpp>

TEST_CASE("basic")
{
auto x = std::variant<int, std::monostate, float>{std::monostate{}};
auto y = cerealize(x);
CHECK(x == y);
}

0 comments on commit 6294fae

Please sign in to comment.