NDDEM
Public Member Functions | List of all members
cereal::detail::PolymorphicCaster Struct Referenceabstract

Base type for polymorphic void casting. More...

#include <polymorphic_impl.hpp>

+ Inheritance diagram for cereal::detail::PolymorphicCaster:

Public Member Functions

 PolymorphicCaster ()=default
 
 PolymorphicCaster (const PolymorphicCaster &)=default
 
PolymorphicCasteroperator= (const PolymorphicCaster &)=default
 
 PolymorphicCaster (PolymorphicCaster &&) CEREAL_NOEXCEPT
 
PolymorphicCasteroperator= (PolymorphicCaster &&) CEREAL_NOEXCEPT
 
virtual ~PolymorphicCaster () CEREAL_NOEXCEPT=default
 
virtual void constdowncast (void const *const ptr) const =0
 Downcasts to the proper derived type. More...
 
virtual void * upcast (void *const ptr) const =0
 Upcast to proper base type. More...
 
virtual std::shared_ptr< void > upcast (std::shared_ptr< void > const &ptr) const =0
 Upcast to proper base type, shared_ptr version. More...
 

Detailed Description

Base type for polymorphic void casting.

Contains functions for casting between registered base and derived types.

This is necessary so that cereal can properly cast between polymorphic types even though void pointers are used, which normally have no type information. Runtime type information is used instead to index a compile-time made mapping that can perform the proper cast. In the case of multiple levels of inheritance, cereal will attempt to find the shortest path by using registered relationships to perform the cast.

This class will be allocated as a StaticObject and only referenced by pointer, allowing a templated derived version of it to define strongly typed functions that cast between registered base and derived types.

Constructor & Destructor Documentation

◆ PolymorphicCaster() [1/3]

cereal::detail::PolymorphicCaster::PolymorphicCaster ( )
default

◆ PolymorphicCaster() [2/3]

cereal::detail::PolymorphicCaster::PolymorphicCaster ( const PolymorphicCaster )
default

◆ PolymorphicCaster() [3/3]

cereal::detail::PolymorphicCaster::PolymorphicCaster ( PolymorphicCaster &&  )
inline

◆ ~PolymorphicCaster()

virtual cereal::detail::PolymorphicCaster::~PolymorphicCaster ( )
virtualdefault

Member Function Documentation

◆ downcast()

virtual void const* cereal::detail::PolymorphicCaster::downcast ( void const *const  ptr) const
pure virtual

Downcasts to the proper derived type.

Implemented in cereal::detail::PolymorphicVirtualCaster< Base, Derived >.

◆ operator=() [1/2]

PolymorphicCaster& cereal::detail::PolymorphicCaster::operator= ( const PolymorphicCaster )
default

◆ operator=() [2/2]

PolymorphicCaster& cereal::detail::PolymorphicCaster::operator= ( PolymorphicCaster &&  )
inline

◆ upcast() [1/2]

virtual std::shared_ptr<void> cereal::detail::PolymorphicCaster::upcast ( std::shared_ptr< void > const ptr) const
pure virtual

Upcast to proper base type, shared_ptr version.

Implemented in cereal::detail::PolymorphicVirtualCaster< Base, Derived >.

◆ upcast() [2/2]

virtual void* cereal::detail::PolymorphicCaster::upcast ( void *const  ptr) const
pure virtual

Upcast to proper base type.

Implemented in cereal::detail::PolymorphicVirtualCaster< Base, Derived >.


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