5 #ifndef TTG_SERIALIZATION_BOOST_H
6 #define TTG_SERIALIZATION_BOOST_H
10 #if __has_include(<boost/type_traits/is_array.hpp>)
11 # define TTG_HAS_BOOST_HEADERS 1
12 # include <boost/type_traits/is_array.hpp>
13 # include <boost/type_traits/remove_extent.hpp>
16 #ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
17 #include <boost/archive/binary_iarchive.hpp>
18 #include <boost/archive/binary_oarchive.hpp>
19 #include <boost/serialization/level.hpp>
26 #ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
28 inline constexpr
bool is_boost_archive_v = std::is_base_of_v<boost::archive::detail::basic_iarchive, T> ||
29 std::is_base_of_v<boost::archive::detail::basic_oarchive, T>;
38 inline constexpr
bool is_archive_v<T, std::enable_if_t<is_boost_archive_v<T>>> =
true;
40 inline constexpr
bool is_input_archive_v<T, std::enable_if_t<is_boost_input_archive_v<T>>> =
true;
42 inline constexpr
bool is_output_archive_v<T, std::enable_if_t<is_boost_output_archive_v<T>>> =
true;
55 template <
typename Archive,
typename T,
typename Enabler =
void>
56 inline static constexpr
bool is_boost_serializable_v =
false;
58 template <
typename Archive,
typename T,
typename Enabler =
void>
61 #ifdef TTG_HAS_BOOST_HEADERS
62 template <
typename Archive,
typename T>
65 template <
typename Archive,
typename T>
67 : std::bool_constant<is_boost_serializable_v<Archive, boost::remove_extent_t<T>>> {};
69 template <
typename Archive,
typename T>
73 template <
typename Archive,
typename T>
76 template <
typename Archive,
typename T>
77 inline static constexpr
bool is_stlcontainer_boost_serializable_v =
false;
79 #ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
84 template <
typename Archive,
typename T>
85 inline static constexpr
bool is_boost_serializable_v<
89 is_boost_archive_v<Archive>
91 && !std::is_same_v<typename boost::serialization::implementation_level<T>::type,
92 boost::mpl::int_<boost::serialization::level_type::not_serializable>>
94 && (std::is_same_v<typename boost::serialization::implementation_level<T>::type,
95 boost::mpl::int_<boost::serialization::level_type::primitive_type>> ||
96 is_boost_array_serializable_v<Archive, T> ||
97 (!std::is_same_v<typename boost::serialization::implementation_level<T>::type,
98 boost::mpl::int_<boost::serialization::level_type::primitive_type>> &&
99 (ttg::detail::has_freestanding_serialize_with_version_v<ttg::meta::remove_cvr_t<T>, Archive> ||
100 (ttg::detail::is_stlcontainer_boost_serializable_v<Archive, T> &&
101 ttg::detail::has_freestanding_boost_serialize_with_version_v<ttg::meta::remove_cvr_t<T>, Archive>) ||
103 (ttg::detail::has_member_load_with_version_v<T, Archive> &&
104 ttg::detail::has_member_save_with_version_v<T, Archive>))))>> =
true;
107 template <
typename Archive,
typename T>
110 template <
typename Archive,
typename T,
class =
void>
113 #ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
115 template <
typename Archive,
typename T>
120 is_boost_archive_v<Archive>
122 && !std::is_same_v<typename boost::serialization::implementation_level<T>::type,
123 boost::mpl::int_<boost::serialization::level_type::not_serializable>>
125 && (std::is_same_v<typename boost::serialization::implementation_level<T>::type,
126 boost::mpl::int_<boost::serialization::level_type::primitive_type>> ||
127 is_boost_array_serializable_v<Archive, T> ||
128 (!std::is_same_v<typename boost::serialization::implementation_level<T>::type,
129 boost::mpl::int_<boost::serialization::level_type::primitive_type>> &&
130 (ttg::detail::is_stlcontainer_boost_serializable_v<Archive, T> &&
131 ttg::detail::has_freestanding_boost_serialize_with_version_v<ttg::meta::remove_cvr_t<T>, Archive>)))>>
135 template <
typename Archive,
typename T>
136 inline static constexpr
bool is_boost_default_serializable_v = is_boost_default_serializable<Archive, T>::value;
138 template <
typename T,
class =
void>
141 #ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
142 template <
typename T>
144 is_boost_serializable_v<boost::archive::binary_oarchive, T>>>
149 template <
typename T>
152 template <
typename T,
class =
void>
155 #ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
156 template <
typename T>
158 T, std::enable_if_t<is_boost_default_serializable_v<boost::archive::binary_iarchive, T> &&
159 is_boost_default_serializable_v<boost::archive::binary_oarchive, T>>> : std::true_type {};
163 template <
typename T>
167 template <
typename T>
constexpr bool is_boost_output_archive_v
constexpr bool has_member_serialize_with_version_v
constexpr bool is_boost_archive_v
constexpr bool is_boost_default_buffer_serializable_v
evaluates to true if can serialize T to/from buffer using default Boost serialization
constexpr bool is_boost_user_buffer_serializable_v
evaluates to true if can serialize T to/from buffer using user-provided Boost serialization
constexpr bool is_boost_input_archive_v
constexpr bool is_boost_buffer_serializable_v
evaluates to true if can serialize T to/from buffer using Boost serialization