30#ifndef CEREAL_TYPES_BOOST_VARIANT_HPP_
31#define CEREAL_TYPES_BOOST_VARIANT_HPP_
34#if defined(_MSC_VER) && _MSC_VER < 1911
35#define CEREAL_CONSTEXPR_LAMBDA
37#define CEREAL_CONSTEXPR_LAMBDA constexpr
41#include <boost/variant/variant_fwd.hpp>
42#include <boost/variant/static_visitor.hpp>
46 namespace boost_variant_detail
49 template <
class Archive>
55 void operator()(T
const & value)
const
64 template <
class Archive,
class T>
67 using ST =
typename std::aligned_storage<
sizeof(T),
CEREAL_ALIGNOF(T)>::type;
81 void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar )
98 template <
class Variant,
class Archive>
99 static void load_variant( Archive &, Variant & )
108 template <
class Archive,
class Variant>
109 static void load_variant_impl( Archive & ar, Variant & variant, std::true_type )
113 variant = std::move(value);
117 template<
class Variant,
class Archive>
118 static void load_variant_impl(Archive & ar, Variant & variant, std::false_type )
123 variant = std::move(*loadWrapper.construct.ptr());
127 template<
class Variant,
class Archive>
128 static void load_variant(Archive & ar, Variant & variant)
130 load_variant_impl( ar, variant,
typename std::is_default_constructible<T>::type() );
136 template <
class Archive,
typename ... VariantTypes>
inline
139 int32_t which = variant.which();
142 variant.apply_visitor(visitor);
146 template <
class Archive,
typename ... VariantTypes>
inline
152 using LoadFuncType = void(*)(Archive &, boost::variant<VariantTypes...> &);
155 if(which >= int32_t(
sizeof(loadFuncArray)/
sizeof(loadFuncArray[0])))
156 throw Exception(
"Invalid 'which' selector when deserializing boost::variant");
158 loadFuncArray[which](ar, variant);
162#undef CEREAL_CONSTEXPR_LAMBDA
Main cereal functionality.
Used to construct types with no default constructor.
Definition: access.hpp:165
#define CEREAL_NVP_(name, value)
Convenience for creating a templated NVP.
Definition: helpers.hpp:201
#define CEREAL_LOAD_FUNCTION_NAME
The deserialization (load) function name to search for.
Definition: macros.hpp:85
#define CEREAL_SAVE_FUNCTION_NAME
The serialization (save) function name to search for.
Definition: macros.hpp:92
#define CEREAL_ALIGNOF
Checks if C++14 is available.
Definition: macros.hpp:153
An exception class thrown when things go wrong at runtime.
Definition: helpers.hpp:49
Definition: boost_variant.hpp:66
Definition: boost_variant.hpp:106
Definition: boost_variant.hpp:51
Definition: traits.hpp:1339