NDDEM
Public Member Functions | Private Attributes | List of all members
cereal::detail::OutputBindingCreator< Archive, T >::PolymorphicSharedPointerWrapper Class Reference

Holds a properly typed shared_ptr to the polymorphic type. More...

#include <polymorphic_impl.hpp>

Public Member Functions

 PolymorphicSharedPointerWrapper (T const *dptr)
 
std::shared_ptr< T const > constoperator() () const
 Get the wrapped shared_ptr *‍/. More...
 

Private Attributes

std::shared_ptr< void > refCount
 The ownership pointer. More...
 
std::shared_ptr< T constwrappedPtr
 The wrapped pointer. More...
 

Detailed Description

template<class Archive, class T>
class cereal::detail::OutputBindingCreator< Archive, T >::PolymorphicSharedPointerWrapper

Holds a properly typed shared_ptr to the polymorphic type.

Constructor & Destructor Documentation

◆ PolymorphicSharedPointerWrapper()

template<class Archive , class T >
cereal::detail::OutputBindingCreator< Archive, T >::PolymorphicSharedPointerWrapper::PolymorphicSharedPointerWrapper ( T const dptr)
inline

Wrap a raw polymorphic pointer in a shared_ptr to its true type

The wrapped pointer will not be responsible for ownership of the held pointer so it will not attempt to destroy it; instead the refcount of the wrapped pointer will be tied to a fake 'ownership pointer' that will do nothing when it ultimately goes out of scope.

The main reason for doing this, other than not to destroy the true object with our wrapper pointer, is to avoid meddling with the internal reference count in a polymorphic type that inherits from std::enable_shared_from_this.

Parameters
dptrA void pointer to the contents of the shared_ptr to serialize

Member Function Documentation

◆ operator()()

template<class Archive , class T >
std::shared_ptr<T const> const& cereal::detail::OutputBindingCreator< Archive, T >::PolymorphicSharedPointerWrapper::operator() ( ) const
inline

Get the wrapped shared_ptr *‍/.

Member Data Documentation

◆ refCount

template<class Archive , class T >
std::shared_ptr<void> cereal::detail::OutputBindingCreator< Archive, T >::PolymorphicSharedPointerWrapper::refCount
private

The ownership pointer.

◆ wrappedPtr

template<class Archive , class T >
std::shared_ptr<T const> cereal::detail::OutputBindingCreator< Archive, T >::PolymorphicSharedPointerWrapper::wrappedPtr
private

The wrapped pointer.


The documentation for this class was generated from the following file: