30 #ifndef CEREAL_TYPES_COMMON_HPP_
31 #define CEREAL_TYPES_COMMON_HPP_
37 namespace common_detail
41 template <
class Archive,
class T>
inline
44 ar( binary_data( array,
sizeof(array) ) );
49 template <
class Archive,
class T>
inline
52 for(
auto & i : array )
60 template <
class T,
bool IsEnum>
61 struct enum_underlying_type : std::false_type {};
67 struct enum_underlying_type<T, true> {
using type =
typename std::underlying_type<T>::type; };
81 using DecayedT =
typename std::decay<T>::type;
82 using StrippedT = typename ::cereal::traits::strip_minimal<DecayedT>::type;
85 static const bool value = std::is_enum<StrippedT>::value;
86 using type = StrippedT;
87 using base_type =
typename enum_underlying_type<StrippedT, value>::type;
92 template <
class Archive,
class T>
inline
93 typename std::enable_if<common_detail::is_enum<T>::value,
94 typename common_detail::is_enum<T>::base_type>::type
97 return static_cast<typename common_detail::is_enum<T>::base_type
>(t);
101 template <
class Archive,
class T>
inline
102 typename std::enable_if<common_detail::is_enum<T>::value,
void>::type
104 typename common_detail::is_enum<T>::base_type
const & value )
106 t =
reinterpret_cast<typename common_detail::is_enum<T>::type
const &
>( value );
111 template <
class Archive,
class T>
inline
115 "Cereal does not support serializing raw pointers - please use a smart pointer");
119 template <
class Archive,
class T>
inline
120 typename std::enable_if<std::is_array<T>::value,
void>::type
123 common_detail::serializeArray( ar, array,
125 std::is_arithmetic<
typename std::remove_all_extents<T>::type>::value>() );
129 #endif // CEREAL_TYPES_COMMON_HPP_