| polymorphic_impl.hpp(3) | Library Functions Manual | polymorphic_impl.hpp(3) |
NAME
polymorphic_impl.hpp - Internal polymorphism support.
SYNOPSIS
#include 'cereal/details/polymorphic_impl_fwd.hpp'
#include 'cereal/details/static_object.hpp'
#include 'cereal/types/memory.hpp'
#include 'cereal/types/string.hpp'
#include <functional>
#include <typeindex>
#include <map>
#include <limits>
#include <set>
#include <stack>
Classes
struct cereal::detail::PolymorphicCaster
Base type for polymorphic void casting. struct
cereal::detail::PolymorphicCasters
Holds registered mappings between base and derived types for casting. struct
cereal::detail::PolymorphicVirtualCaster< Base, Derived >
Strongly typed derivation of PolymorphicCaster. struct
cereal::detail::RegisterPolymorphicCaster< Base, Derived >
Registers a polymorphic casting relation between a Base and Derived type.
struct cereal::detail::binding_name< T >
Binds a compile time type with a user defined string. struct
cereal::detail::OutputBindingMap< Archive >
A structure holding a map from type_indices to output serializer functions.
struct cereal::detail::OutputBindingMap< Archive >::Serializers
Struct containing the serializer functions for all pointer types. struct
cereal::detail::EmptyDeleter< T >
An empty noop deleter. struct cereal::detail::InputBindingMap< Archive
>
A structure holding a map from type name strings to input serializer
functions. struct cereal::detail::InputBindingMap< Archive
>::Serializers
Struct containing the serializer functions for all pointer types. struct
cereal::detail::InputBindingCreator< Archive, T >
Creates a binding (map entry) between an input archive type and a polymorphic
type. struct cereal::detail::OutputBindingCreator< Archive, T >
Creates a binding (map entry) between an output archive type and a polymorphic
type. class cereal::detail::OutputBindingCreator< Archive, T
>::PolymorphicSharedPointerWrapper
Holds a properly typed shared_ptr to the polymorphic type. struct
cereal::detail::adl_tag
struct cereal::detail::create_bindings< Archive, T >
Causes the static object bindings between an archive type and a serializable
type T. struct cereal::detail::instantiate_function<>
When specialized, causes the compiler to instantiate its parameter. struct
cereal::detail::polymorphic_serialization_support< Archive, T >
struct cereal::detail::bind_to_archives< T, Tag >
Begins the binding process of a type to all registered archives.
Macros
#define CEREAL_BIND_TO_ARCHIVES_UNUSED_FUNCTION static void
unused() { (void)b; }
Helper macro to omit unused warning. #define
CEREAL_BIND_TO_ARCHIVES(...)
Binds a polymorhic type to all registered archives. #define
UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION(LoadSave)
Error message used for unregistered polymorphic casts. #define
CEREAL_EMPLACE_MAP(map, key, value)
Functions
template<class T, typename BindingTag> void
cereal::detail::instantiate_polymorphic_binding (T *, int,
BindingTag, adl_tag)
Base case overload for instantiation.
Detailed Description
Internal polymorphism support.
Macro Definition Documentation
#define CEREAL_BIND_TO_ARCHIVES( ...)
Value:
namespace cereal { \
namespace detail { \
template<> \
struct init_binding<__VA_ARGS__> { \
static bind_to_archives<__VA_ARGS__> const& b; \
CEREAL_BIND_TO_ARCHIVES_UNUSED_FUNCTION \
}; \
bind_to_archives<__VA_ARGS__> const & init_binding<__VA_ARGS__>::b = \
::cereal::detail::StaticObject< \
bind_to_archives<__VA_ARGS__> \
>::getInstance().bind(); \
}}
Binds a polymorhic type to all registered archives. This binds a polymorphic type to all compatible registered archives that have been registered with CEREAL_REGISTER_ARCHIVE. This must be called after all archives are registered (usually after the archives themselves have been included).
#define CEREAL_EMPLACE_MAP( map, key, value)
Value:
map.emplace( key, value );
#define UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION( LoadSave)
Value:
throw cereal::Exception("Trying to " #LoadSave " a registered polymorphic type with an unregistered polymorphic cast.\n" \
"Could not find a path to a base class (" + util::demangle(baseInfo.name()) + ") for type: " + ::cereal::util::demangledName<Derived>() + "\n" \
"Make sure you either serialize the base class at some point via cereal::base_class or cereal::virtual_base_class.\n" \
"Alternatively, manually register the association with CEREAL_REGISTER_POLYMORPHIC_RELATION.");
Error message used for unregistered polymorphic casts.
Function Documentation
template<class T, typename BindingTag> void cereal::detail::instantiate_polymorphic_binding (T * , int , BindingTag , adl_tag )
Base case overload for instantiation. This will end up always being the best overload due to the second parameter always being passed as an int. All other overloads will accept pointers to archive types and have lower precedence than int.
Since the compiler needs to check all possible overloads, the other overloads created via CEREAL_REGISTER_ARCHIVE, which will have lower precedence due to requring a conversion from int to (Archive*), will cause their return types to be instantiated through the static object mechanisms even though they are never called.
See the documentation for the other functions to try and understand this
Author
Generated automatically by Doxygen for cereal from the source code.
| Mon Oct 26 2026 02:55:37 | cereal |