memory.hpp File Reference
Support for Serializing Various Types » Standard Library Support

Support for types found in <memory> More...

`#include "cereal/cereal.hpp"`
`#include <memory>`
`#include <cstring>`
`#include "cereal/types/polymorphic.hpp"`

Go to the source code of this file.

## Classes

struct | cereal::memory_detail::PtrWrapper< T >
| A wrapper class to notify cereal that it is ok to serialize the contained pointer. More...
struct | cereal::memory_detail::LoadAndConstructLoadWrapper< Archive, T >
| A struct that acts as a wrapper around calling load_andor_construct. More...
class | cereal::memory_detail::EnableSharedStateHelper< T >

## Functions

template<class T >
PtrWrapper< T > | cereal::memory_detail::make_ptr_wrapper (T &&t)
| Make a PtrWrapper.
template<class Archive , class T >
void | cereal::memory_detail::loadAndConstructSharedPtr (Archive &ar, T *ptr, std::true_type)
template<class Archive , class T >
void | cereal::memory_detail::loadAndConstructSharedPtr (Archive &ar, T *ptr, std::false_type)
template<class Archive , class T >
std::enable_if<!std::is_polymorphic< T >::value, void >::type | cereal::CEREAL_SAVE_FUNCTION_NAME (Archive &ar, std::shared_ptr< T > const &ptr)
| Saving std::shared_ptr for non polymorphic types.
template<class Archive , class T >
std::enable_if<!std::is_polymorphic< T >::value, void >::type | cereal::CEREAL_LOAD_FUNCTION_NAME (Archive &ar, std::shared_ptr< T > &ptr)
| Loading std::shared_ptr, case when no user load and construct for non polymorphic types.
template<class Archive , class T >
std::enable_if<!std::is_polymorphic< T >::value, void >::type | cereal::CEREAL_SAVE_FUNCTION_NAME (Archive &ar, std::weak_ptr< T > const &ptr)
| Saving std::weak_ptr for non polymorphic types.
template<class Archive , class T >
std::enable_if<!std::is_polymorphic< T >::value, void >::type | cereal::CEREAL_LOAD_FUNCTION_NAME (Archive &ar, std::weak_ptr< T > &ptr)
| Loading std::weak_ptr for non polymorphic types.
template<class Archive , class T , class D >
std::enable_if<!std::is_polymorphic< T >::value, void >::type | cereal::CEREAL_SAVE_FUNCTION_NAME (Archive &ar, std::unique_ptr< T, D > const &ptr)
| Saving std::unique_ptr for non polymorphic types.
template<class Archive , class T , class D >
std::enable_if<!std::is_polymorphic< T >::value, void >::type | cereal::CEREAL_LOAD_FUNCTION_NAME (Archive &ar, std::unique_ptr< T, D > &ptr)
| Loading std::unique_ptr, case when user provides load_and_construct for non polymorphic types.
template<class Archive , class T >
void | cereal::CEREAL_SAVE_FUNCTION_NAME (Archive &ar, memory_detail::PtrWrapper< std::shared_ptr< T > const & > const &wrapper)
| Saving std::shared_ptr (wrapper implementation)
template<class Archive , class T >
std::enable_if< traits::has_load_and_construct< T, Archive >::value, void >::type | cereal::CEREAL_LOAD_FUNCTION_NAME (Archive &ar, memory_detail::PtrWrapper< std::shared_ptr< T > & > &wrapper)
| Loading std::shared_ptr, case when user load and construct (wrapper implementation)
template<class Archive , class T >
std::enable_if<!traits::has_load_and_construct< T, Archive >::value, void >::type | cereal::CEREAL_LOAD_FUNCTION_NAME (Archive &ar, memory_detail::PtrWrapper< std::shared_ptr< T > & > &wrapper)
| Loading std::shared_ptr, case when no user load and construct (wrapper implementation)
template<class Archive , class T , class D >
void | cereal::CEREAL_SAVE_FUNCTION_NAME (Archive &ar, memory_detail::PtrWrapper< std::unique_ptr< T, D > const & > const &wrapper)
| Saving std::unique_ptr (wrapper implementation)
template<class Archive , class T , class D >
std::enable_if< traits::has_load_and_construct< T, Archive >::value, void >::type | cereal::CEREAL_LOAD_FUNCTION_NAME (Archive &ar, memory_detail::PtrWrapper< std::unique_ptr< T, D > & > &wrapper)
| Loading std::unique_ptr, case when user provides load_and_construct (wrapper implementation)
template<class Archive , class T , class D >
std::enable_if<!traits::has_load_and_construct< T, Archive >::value, void >::type | cereal::CEREAL_LOAD_FUNCTION_NAME (Archive &ar, memory_detail::PtrWrapper< std::unique_ptr< T, D > & > &wrapper)
| Loading std::unique_ptr, case when no load_and_construct (wrapper implementation)

## Detailed Description

Support for types found in <memory>

## Function Documentation

## loadAndConstructSharedPtr() [1/2]

template<class Archive , class T >

void cereal::memory_detail::loadAndConstructSharedPtr | ( | Archive & | ar,
|  | T * | ptr,
|  | std::false_type |
| ) |  |

inline

Performs loading and construction for a shared pointer that is NOT derived from std::enable_shared_from_this

This is the typical case, where we simply pass the load wrapper to the archive.

Parameters

  ar | The archive
  ptr | Raw pointer held by the shared_ptr

## loadAndConstructSharedPtr() [2/2]

template<class Archive , class T >

void cereal::memory_detail::loadAndConstructSharedPtr | ( | Archive & | ar,
|  | T * | ptr,
|  | std::true_type |
| ) |  |

inline

Performs loading and construction for a shared pointer that is derived from std::enable_shared_from_this

Parameters

  ar | The archive
  ptr | Raw pointer held by the shared_ptr