14 #ifndef MLPACK_CORE_CEREAL_ARRAY_WRAPPER_HPP 15 #define MLPACK_CORE_CEREAL_ARRAY_WRAPPER_HPP 17 #include <cereal/archives/binary.hpp> 18 #include <cereal/archives/portable_binary.hpp> 19 #include <cereal/archives/xml.hpp> 20 #include <cereal/archives/json.hpp> 36 template<
class Archive>
37 void save(Archive& ar)
const 39 ar(CEREAL_NVP(arraySize));
40 for (
size_t i = 0; i < arraySize; ++i)
41 ar(cereal::make_nvp(
"item", arrayAddress[i]));
44 template<
class Archive>
47 ar(CEREAL_NVP(arraySize));
48 delete[] arrayAddress;
54 arrayAddress =
new T[arraySize];
55 for (
size_t i = 0; i < arraySize; ++i)
56 ar(cereal::make_nvp(
"item", arrayAddress[i]));
72 template<
class T,
class S>
87 #define CEREAL_POINTER_ARRAY(T, S) cereal::make_array(T, S) 91 #endif // CEREAL_ARRAY_WRAPPER_HPP ArrayWrapper< T > make_array(T *&t, S &s)
This function is used to serialized old c-style array.
This class is used as a shim for cereal to be able to serialize a raw pointer array.
ArrayWrapper(T *&addr, std::size_t &size)
void save(Archive &ar) const