6#ifndef TTG_SERIALIZATION_BOOST_H
7#define TTG_SERIALIZATION_BOOST_H
11#if __has_include(<boost/type_traits/is_array.hpp>)
12# define TTG_HAS_BOOST_HEADERS 1
13# include <boost/type_traits/is_array.hpp>
14# include <boost/type_traits/remove_extent.hpp>
17#ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
18#include <boost/archive/binary_iarchive.hpp>
19#include <boost/archive/binary_oarchive.hpp>
20#include <boost/serialization/level.hpp>
27#ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
29 inline constexpr bool is_boost_archive_v = std::is_base_of_v<boost::archive::detail::basic_iarchive, T> ||
30 std::is_base_of_v<boost::archive::detail::basic_oarchive, T>;
39 inline constexpr bool is_archive_v<T, std::enable_if_t<is_boost_archive_v<T>>> =
true;
41 inline constexpr bool is_input_archive_v<T, std::enable_if_t<is_boost_input_archive_v<T>>> =
true;
43 inline constexpr bool is_output_archive_v<T, std::enable_if_t<is_boost_output_archive_v<T>>> =
true;
56 template <
typename Archive,
typename T,
typename Enabler =
void>
57 inline static constexpr bool is_boost_serializable_v =
false;
59 template <
typename Archive,
typename T,
typename Enabler =
void>
62#ifdef TTG_HAS_BOOST_HEADERS
63 template <
typename Archive,
typename T>
66 template <
typename Archive,
typename T>
68 : std::bool_constant<is_boost_serializable_v<Archive, boost::remove_extent_t<T>>> {};
70 template <
typename Archive,
typename T>
74 template <
typename Archive,
typename T>
77 template <
typename Archive,
typename T>
78 inline static constexpr bool is_stlcontainer_boost_serializable_v =
false;
80#ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
85 template <
typename Archive,
typename T>
86 inline static constexpr bool is_boost_serializable_v<
90 is_boost_archive_v<Archive>
92 && !std::is_same_v<typename boost::serialization::implementation_level<T>::type,
93 boost::mpl::int_<boost::serialization::level_type::not_serializable>>
95 && (std::is_same_v<typename boost::serialization::implementation_level<T>::type,
96 boost::mpl::int_<boost::serialization::level_type::primitive_type>> ||
97 is_boost_array_serializable_v<Archive, T> ||
98 (!std::is_same_v<typename boost::serialization::implementation_level<T>::type,
99 boost::mpl::int_<boost::serialization::level_type::primitive_type>> &&
100 (ttg::detail::has_freestanding_serialize_with_version_v<ttg::meta::remove_cvr_t<T>, Archive> ||
101 (ttg::detail::is_stlcontainer_boost_serializable_v<Archive, T> &&
102 ttg::detail::has_freestanding_boost_serialize_with_version_v<ttg::meta::remove_cvr_t<T>, Archive>) ||
104 (ttg::detail::has_member_load_with_version_v<T, Archive> &&
105 ttg::detail::has_member_save_with_version_v<T, Archive>))))>> =
true;
108 template <
typename Archive,
typename T>
111 template <
typename Archive,
typename T,
class =
void>
114#ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
116 template <
typename Archive,
typename T>
121 is_boost_archive_v<Archive>
123 && !std::is_same_v<typename boost::serialization::implementation_level<T>::type,
124 boost::mpl::int_<boost::serialization::level_type::not_serializable>>
126 && (std::is_same_v<typename boost::serialization::implementation_level<T>::type,
127 boost::mpl::int_<boost::serialization::level_type::primitive_type>> ||
128 is_boost_array_serializable_v<Archive, T> ||
129 (!std::is_same_v<typename boost::serialization::implementation_level<T>::type,
130 boost::mpl::int_<boost::serialization::level_type::primitive_type>> &&
131 (ttg::detail::is_stlcontainer_boost_serializable_v<Archive, T> &&
132 ttg::detail::has_freestanding_boost_serialize_with_version_v<ttg::meta::remove_cvr_t<T>, Archive>)))>>
136 template <
typename Archive,
typename T>
137 inline static constexpr bool is_boost_default_serializable_v = is_boost_default_serializable<Archive, T>::value;
139 template <
typename T,
class =
void>
142#ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
143 template <
typename T>
145 is_boost_serializable_v<boost::archive::binary_oarchive, T>>>
150 template <
typename T>
153 template <
typename T,
class =
void>
156#ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
157 template <
typename T>
159 T,
std::enable_if_t<is_boost_default_serializable_v<boost::archive::binary_iarchive, T> &&
160 is_boost_default_serializable_v<boost::archive::binary_oarchive, T>>> : std::true_type {};
164 template <
typename T>
168 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