1313#include < boost/config.hpp>
1414#include < boost/serialization/strong_typedef.hpp>
1515
16+ if !defined (BOOST_NO_CXX11_HDR_TYPE_TRAITS)
17+ #include < type_traits> // For std::is_same, std::enable_if
18+ #endif
19+
1620// ///////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
1721// serialization.hpp: interface for serialization system.
1822
@@ -60,6 +64,44 @@ namespace serialization {
6064
6165BOOST_STRONG_TYPEDEF (unsigned int , version_type)
6266
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+
63105// default implementation - call the member function "serialize"
64106template <class Archive , class T >
65107inline void serialize (
@@ -68,6 +110,8 @@ inline void serialize(
68110 access::serialize (ar, t, static_cast <unsigned int >(file_version));
69111}
70112
113+ #endif // __cplusplus==201103L
114+
71115// save data required for construction
72116template <class Archive , class T >
73117inline void save_construct_data (
0 commit comments