Skip to content
Welcome to the new CppUtils documentation!

Diagnostic utility for tracking and validating object lifecycles in unit tests.

Monitors default construction, copy, move, and destruction events via a callback logger, while maintaining thread-safe atomic counters for copy and move operations.

LifetimeChecker::LifetimeChecker(std::function<void(std::string_view)> callback, std::string name, std::size_t indentationLevel = 0);

Constructs a LifetimeChecker and logs object creation.

ParameterDescription
callbackLogging callback receiving string views of lifecycle events.
nameDiagnostic identifier of the monitored object.
indentationLevelTab indentation level for hierarchical visual logging.
[[nodiscard]] auto LifetimeChecker::getCopyCount() const -> std::size_t;

Returns the total number of copy constructions and copy assignments performed.

Returns: Cumulative copy operation count.

[[nodiscard]] auto LifetimeChecker::getMoveCount() const -> std::size_t;

Returns the total number of move constructions and move assignments performed.

Returns: Cumulative move operation count.

virtual LifetimeChecker::~LifetimeChecker();

Destroys the LifetimeChecker and logs the destruction event.

LifetimeChecker::LifetimeChecker(const LifetimeChecker& other);
LifetimeChecker::LifetimeChecker(LifetimeChecker&& other) noexcept;
auto LifetimeChecker::operator=(const LifetimeChecker& rhs) -> LifetimeChecker&;
auto LifetimeChecker::operator=(LifetimeChecker&& rhs) noexcept -> LifetimeChecker&;