polymorphic\_impl.hpp(3) Library Functions Manual polymorphic\_impl.hpp(3)

# [NAME](#NAME)

polymorphic\_impl.hpp - Internal polymorphism support.

# [SYNOPSIS](#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 &lt;functional&gt;  
#include &lt;typeindex&gt;  
#include &lt;map&gt;  
#include &lt;limits&gt;  
#include &lt;set&gt;  
#include &lt;stack&gt;

## [Classes](#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&lt; Base, Derived &gt;**  
Strongly typed derivation of **PolymorphicCaster**. struct **cereal::detail::RegisterPolymorphicCaster&lt; Base, Derived &gt;**  
Registers a polymorphic casting relation between a Base and Derived type. struct **cereal::detail::binding\_name&lt; T &gt;**  
Binds a compile time type with a user defined string. struct **cereal::detail::OutputBindingMap&lt; Archive &gt;**  
A structure holding a map from type\_indices to output serializer functions. struct **cereal::detail::OutputBindingMap&lt; Archive &gt;::Serializers**  
Struct containing the serializer functions for all pointer types. struct **cereal::detail::EmptyDeleter&lt; T &gt;**  
An empty noop deleter. struct **cereal::detail::InputBindingMap&lt; Archive &gt;**  
A structure holding a map from type name strings to input serializer functions. struct **cereal::detail::InputBindingMap&lt; Archive &gt;::Serializers**  
Struct containing the serializer functions for all pointer types. struct **cereal::detail::InputBindingCreator&lt; Archive, T &gt;**  
Creates a binding (map entry) between an input archive type and a polymorphic type. struct **cereal::detail::OutputBindingCreator&lt; Archive, T &gt;**  
Creates a binding (map entry) between an output archive type and a polymorphic type. class **cereal::detail::OutputBindingCreator&lt; Archive, T &gt;::PolymorphicSharedPointerWrapper**  
Holds a properly typed shared\_ptr to the polymorphic type. struct **cereal::detail::adl\_tag**  
struct **cereal::detail::create\_bindings&lt; Archive, T &gt;**  
Causes the static object bindings between an archive type and a serializable type T. struct **cereal::detail::instantiate\_function&lt;&gt;**  
When specialized, causes the compiler to instantiate its parameter. struct **cereal::detail::polymorphic\_serialization\_support&lt; Archive, T &gt;**  
struct **cereal::detail::bind\_to\_archives&lt; T, Tag &gt;**  
Begins the binding process of a type to all registered archives.

## [Macros](#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](#Functions)

template&lt;class T, typename BindingTag&gt; void **cereal::detail::instantiate\_polymorphic\_binding** (T \*, int, BindingTag, **adl\_tag**)  
Base case overload for instantiation.

# [Detailed Description](#Detailed_Description)

Internal polymorphism support.

# [Macro Definition Documentation](#Macro_Definition_Documentation)

## [#define CEREAL\_BIND\_TO\_ARCHIVES( ...)](#_define_CEREAL_BIND_TO_ARCHIVES%28_)

**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)](#_define_CEREAL_EMPLACE_MAP%28_map,__key,__value%29)

**Value:**

```
map.emplace( key, value );
```

```

```

## [#define UNREGISTERED\_POLYMORPHIC\_CAST\_EXCEPTION( LoadSave)](#_define_UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION%28_LoadSave%29)

**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](#Function_Documentation)

## [template&lt;class T, typename BindingTag&gt; void cereal::detail::instantiate\_polymorphic\_binding (T * , int , BindingTag , **adl\_tag** )](#template_class_T,_typename_BindingTag__void_cereal::detail::instantiate_polymorphic_binding_%28T_*_,_int_,_BindingTag_,_)

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](#Author)

Generated automatically by Doxygen for cereal from the source code.

Sat Oct 10 2026 08:08:15 cereal

---

Document: polymorphic_impl.hpp(3) from cereal 1.3.2-r6 (Chainguard OS)
Source: https://github.com/USCiLab/cereal
