cereal::detail::StaticObject&lt; T &gt;(3) Library Functions Manual cereal::detail::StaticObject&lt; T &gt;(3)

# [NAME](#NAME)

cereal::detail::StaticObject&lt; T &gt; - A static, pre-execution object.

# [SYNOPSIS](#SYNOPSIS)

#include &lt;/home/build/include/cereal/details/static\_object.hpp&gt;

## [Classes](#Classes)

class **LockGuard**  
A class that acts like std::lock\_guard.

## [Static Public Member Functions](#Static_Public_Member_Functions)

static T & **getInstance** ()  
static **LockGuard** **lock** ()  
Attempts to lock this static object for the current scope.

# [Detailed Description](#Detailed_Description)

## [template&lt;class T&gt;](#template_class_T_)

class cereal::detail::StaticObject&lt; T &gt;"A static, pre-execution object.

This class will create a single copy (singleton) of some type and ensures that merely referencing this type will cause it to be instantiated and initialized pre-execution. For example, this is used heavily in the polymorphic pointer serialization mechanisms to bind various archive types with different polymorphic classes

# [Member Function Documentation](#Member_Function_Documentation)

## [template&lt;class T&gt; **LockGuard** **cereal::detail::StaticObject**&lt; T &gt;::lock () \[inline\], \[static\]](#template_class_T__)

Attempts to lock this static object for the current scope.

**Note**

This function is a no-op if cereal is not compiled with thread safety enabled (CEREAL\_THREAD\_SAFE = 1).

This function returns an object that holds a lock for this **StaticObject** that will release its lock upon destruction. This call will block until the lock is available.

# [Author](#Author)

Generated automatically by Doxygen for cereal from the source code.

Sat Aug 29 2026 00:42:30 cereal

---

Document: cereal_detail_StaticObject(3) from cereal 1.3.2-r5 (Chainguard OS)
Source: https://github.com/USCiLab/cereal
