From 150cb8dcbd2868a2f64305c60e05216a5c60b689 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Thu, 13 Aug 2026 17:24:07 +0200 Subject: [PATCH] Deprecate std_variant.hpp and remove variant2.hpp Support for `boost::variant`, `boost::variant2::variant` and `std::variant` has moved to variant.hpp. std_variant.hpp still compiled on its own, so it stays as a deprecated forwarding header. variant2.hpp could not have a working user: it declared a partial specialization whose argument list is identical to the primary template, which is ill-formed. It has been that way since 897dec4c, the commit which gave `variant.hpp` its own variant2 support. So we remove it. --- include/boost/serialization/std_variant.hpp | 191 +------------------- include/boost/serialization/variant2.hpp | 174 ------------------ test/Jamfile.v2 | 1 + test/test_std_variant_forwarding.cpp | 39 ++++ 4 files changed, 50 insertions(+), 355 deletions(-) delete mode 100644 include/boost/serialization/variant2.hpp create mode 100644 test/test_std_variant_forwarding.cpp diff --git a/include/boost/serialization/std_variant.hpp b/include/boost/serialization/std_variant.hpp index 8d38c8f07..0b54e0e78 100644 --- a/include/boost/serialization/std_variant.hpp +++ b/include/boost/serialization/std_variant.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// variant.hpp - non-intrusive serialization of variant types +// std_variant.hpp - deprecated, forwards to variant.hpp // // copyright (c) 2019 Samuel Debionne, ESRF // @@ -17,188 +17,17 @@ // // See http://www.boost.org for updates, documentation, and revision history. // -// Widely inspired form boost::variant serialization -// - -#include - -#include - -#include - -#include -#include -#include - -namespace boost { -namespace serialization { - -template -struct std_variant_save_visitor -{ - std_variant_save_visitor(Archive& ar) : - m_ar(ar) - {} - template - void operator()(T const & value) const - { - m_ar << BOOST_SERIALIZATION_NVP(value); - } -private: - Archive & m_ar; -}; - - -template -struct std_variant_load_visitor -{ - std_variant_load_visitor(Archive& ar) : - m_ar(ar) - {} - template - void operator()(T & value) const - { - m_ar >> BOOST_SERIALIZATION_NVP(value); - } -private: - Archive & m_ar; -}; - -template -void save( - Archive & ar, - std::variant const & v, - unsigned int /*version*/ -){ - const std::size_t which = v.index(); - ar << BOOST_SERIALIZATION_NVP(which); - std_variant_save_visitor visitor(ar); - std::visit(visitor, v); -} - -// Minimalist metaprogramming for handling parameter pack -namespace mp { - namespace detail { - template - struct front_impl; - - template