13 #ifndef MLPACK_CORE_CEREAL_POINTER_WRAPPER_HPP 14 #define MLPACK_CORE_CEREAL_POINTER_WRAPPER_HPP 16 #include <cereal/archives/binary.hpp> 17 #include <cereal/archives/json.hpp> 18 #include <cereal/archives/portable_binary.hpp> 19 #include <cereal/archives/xml.hpp> 20 #include <cereal/types/memory.hpp> 22 #if __cplusplus <= 201103L && !defined(_MSC_VER) 24 template<
typename T,
typename... Args>
25 std::unique_ptr<T> make_unique(Args&&... args)
27 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
48 : localPointer(pointer)
51 template<
class Archive>
52 void save(Archive& ar,
const uint32_t )
const 54 std::unique_ptr<T> smartPointer;
55 if (this->localPointer != NULL)
56 smartPointer = std::unique_ptr<T>(localPointer);
57 ar(CEREAL_NVP(smartPointer));
58 localPointer = smartPointer.release();
61 template<
class Archive>
62 void load(Archive& ar,
const uint32_t )
64 std::unique_ptr<T> smartPointer;
65 ar(CEREAL_NVP(smartPointer));
66 localPointer = smartPointer.release();
69 T*& release() {
return localPointer; }
96 #define CEREAL_POINTER(T) cereal::make_pointer(T) 100 #endif // CEREAL_POINTER_WRAPPER_HPP The objective of this class is to create a wrapper for raw pointer by encapsulating them in a smart p...
Definition: pointer_wrapper.hpp:44
Definition: pointer_wrapper.hpp:23
Add an external serialization function for SpMat.
Definition: serialize_armadillo.hpp:26
PointerWrapper< T > make_pointer(T *&t)
Serialize raw pointer object by encapsulating the pointer into a smart pointer.
Definition: pointer_wrapper.hpp:83