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>() );
Main cereal functionality.
Checks if a type is an enum.
Definition: common.hpp:79
void serializeArray(Archive &ar, T &array, std::true_type)
Serialization for arrays if BinaryData is supported and we are arithmetic.
Definition: common.hpp:42
#define CEREAL_LOAD_MINIMAL_FUNCTION_NAME
The deserialization (load_minimal) function name to search for.
Definition: macros.hpp:99
#define CEREAL_SAVE_MINIMAL_FUNCTION_NAME
The serialization (save_minimal) function name to search for.
Definition: macros.hpp:106
#define CEREAL_SERIALIZE_FUNCTION_NAME
The serialization/deserialization function name to search for.
Definition: macros.hpp:78
A wrapper around data that can be serialized in a binary fashion.
Definition: helpers.hpp:212
Used to delay a static_assert until template instantiation.
Definition: traits.hpp:57
Definition: traits.hpp:1112