13
13
#include < boost/config.hpp>
14
14
#include < boost/serialization/strong_typedef.hpp>
15
15
16
+ if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
17
+ #include < type_traits> // For std::is_same, std::enable_if
18
+ #endif
19
+
16
20
// ///////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
17
21
// serialization.hpp: interface for serialization system.
18
22
@@ -60,6 +64,44 @@ namespace serialization {
60
64
61
65
BOOST_STRONG_TYPEDEF (unsigned int , version_type)
62
66
67
+ #if __cplusplus==201103L
68
+
69
+ namespace detail {
70
+
71
+ struct has_serialize
72
+ {
73
+
74
+ private:
75
+ template <class T >
76
+ static constexpr auto check (T*)
77
+ -> typename
78
+ std::is_same<
79
+ decltype(std::declval<T>().serialize(std::declval<Archive&>(), std::declval<unsigned int>())),
80
+ void
81
+ >::type;
82
+
83
+ template <class >
84
+ static constexpr std::false_type check (...);
85
+
86
+ typedef decltype (check<C>(0 )) type;
87
+
88
+ public:
89
+ static constexpr bool value = type::value;
90
+ };
91
+
92
+ } // namespace detail
93
+
94
+ // default implementation - call the member function "serialize" if it exists,
95
+ // else removed from overload resolution.
96
+ template <class Archive , class T >
97
+ inline typename std::enable_if<detail::has_serialize<Archive, T>::value>::type serialize (
98
+ Archive & ar, T & t, const unsigned int file_version
99
+ ){
100
+ access ::serialize (ar, t, static_cast <unsigned int >(file_version));
101
+ }
102
+
103
+ #else // __cplusplus==201103L
104
+
63
105
// default implementation - call the member function "serialize"
64
106
template <class Archive , class T >
65
107
inline void serialize (
@@ -68,6 +110,8 @@ inline void serialize(
68
110
access ::serialize (ar, t, static_cast <unsigned int >(file_version));
69
111
}
70
112
113
+ #endif // __cplusplus==201103L
114
+
71
115
// save data required for construction
72
116
template <class Archive , class T >
73
117
inline void save_construct_data (
0 commit comments