12 #ifndef SST_CORE_SERIALIZATION_IMPL_SERIALIZE_VARIANT_H 13 #define SST_CORE_SERIALIZATION_IMPL_SERIALIZE_VARIANT_H 15 #ifndef SST_INCLUDING_SERIALIZE_H 17 "The header file sst/core/serialization/impl/serialize_variant.h should not be directly included as it is not part of the stable public API. The file is included in sst/core/serialization/serialize.h" 20 #include "sst/core/serialization/serializer.h" 29 template <
typename... Types>
32 void operator()(std::variant<Types...>& obj,
serializer& ser, ser_opt_t UNUSED(options))
34 size_t index = std::variant_npos;
35 switch ( ser.mode() ) {
36 case serializer::SIZER:
41 case serializer::PACK:
46 case serializer::UNPACK:
51 if ( index != std::variant_npos ) set_index<std::index_sequence_for<Types...>>::array.at(index)(obj);
65 if ( index != std::variant_npos ) std::visit([&](
auto& x) { SST_SER(x); }, obj);
94 template <
size_t INDEX>
95 static void set_index_func(std::variant<Types...>& obj)
97 obj.template emplace<INDEX>();
100 template <
size_t... INDEX>
101 struct set_index<std::index_sequence<INDEX...>>
103 static constexpr std::array<void (*)(std::variant<Types...>& obj),
sizeof...(INDEX)> array = {
104 set_index_func<INDEX>...
108 SST_FRIEND_SERIALIZE();
113 #endif // SST_CORE_SERIALIZATION_IMPL_SERIALIZE_VARIANT_H This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:42
Base serialize class.
Definition: serialize.h:113