microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Public Member Functions | List of all members
microfmt::counting_sink Class Reference

Output sink that counts total formatted bytes without storing characters. More...

#include <microfmt.hpp>

Public Member Functions

constexpr counting_sink () noexcept=default
 Constructs a counting sink with a zero byte count.
 
RELOCO_BEGIN_UNSAFE_CODE sink as_sink () &noexcept RELOCO_LIFETIMEBOUND
 Creates a type-erased sink adapter pointing to this instance.
 
RELOCO_END_UNSAFE_CODE constexpr std::size_t count () const noexcept
 Returns the total number of bytes written to the sink.
 
RELOCO_REINITIALIZES constexpr void reset () noexcept
 Resets the internal counter to zero.
 

Detailed Description

Output sink that counts total formatted bytes without storing characters.

Useful for computing required buffer sizes before performing an allocation or determining truncation lengths without runtime side-effects.

Constructor & Destructor Documentation

◆ counting_sink()

constexpr microfmt::counting_sink::counting_sink ( )
constexprdefaultnoexcept

Constructs a counting sink with a zero byte count.

Member Function Documentation

◆ as_sink()

RELOCO_BEGIN_UNSAFE_CODE sink microfmt::counting_sink::as_sink ( ) &
inlinenoexcept

Creates a type-erased sink adapter pointing to this instance.

Returns
A lightweight sink struct configured to increment the internal counter.

◆ count()

RELOCO_END_UNSAFE_CODE constexpr std::size_t microfmt::counting_sink::count ( ) const
inlineconstexprnoexcept

Returns the total number of bytes written to the sink.

Returns
Total character count.

◆ reset()

RELOCO_REINITIALIZES constexpr void microfmt::counting_sink::reset ( )
inlineconstexprnoexcept

Resets the internal counter to zero.


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