Type-erased, two-word handle to a sink backend.
More...
#include <sink_provider.hpp>
|
| constexpr | sink_provider_ref () noexcept=default |
| | Constructs an empty (invalid) handle.
|
| |
| template<typename Tag , typename Traits = sink_provider_traits<Tag>, std::enable_if_t< std::is_void_v< typename Traits::context_type >, int > = 0> |
| constexpr | sink_provider_ref (Tag) noexcept |
| | Constructs a handle for a stateless sink tag.
|
| |
| template<typename Tag , typename Context , typename Traits = sink_provider_traits<Tag>, std::enable_if_t<!std::is_void_v< typename Traits::context_type > &&std::is_convertible_v< Context *, typename Traits::context_type * >, int > = 0> |
| constexpr | sink_provider_ref (Tag, Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept |
| | Constructs a handle for a stateful sink tag.
|
| |
| template<typename Tag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0> |
| constexpr | sink_provider_ref (Tag, Context &&)=delete |
| |
| void | write (microfmt::string_view sv) const noexcept |
| | Emits a sequence of characters to the underlying sink.
|
| |
| constexpr bool | can_flush () const noexcept |
| | Reports whether the bound backend supports flush.
|
| |
| void | flush () const noexcept |
| | Flushes buffered output. A no-op when can_flush is false.
|
| |
| constexpr | operator bool () const noexcept |
| | Reports whether the handle is bound to a sink backend.
|
| |
| constexpr sink | as_sink () const noexcept RELOCO_LIFETIMEBOUND |
| | Bridges to a plain microfmt::sink, for use with format_to/vformat_to.
|
| |
Type-erased, two-word handle to a sink backend.
Packs a context pointer and a vtable pointer into two words: no virtual base class, no RTTI, and no allocation of its own. The bound context (for stateful tags) must outlive every sink_provider_ref built from it. Converts to microfmt::sink via as_sink so it plugs directly into format_to/vformat_to.
◆ sink_provider_ref() [1/4]
| constexpr microfmt::sink_provider_ref::sink_provider_ref |
( |
| ) |
|
|
constexprdefaultnoexcept |
Constructs an empty (invalid) handle.
◆ sink_provider_ref() [2/4]
template<typename Tag , typename Traits = sink_provider_traits<Tag>, std::enable_if_t< std::is_void_v< typename Traits::context_type >, int > = 0>
| constexpr microfmt::sink_provider_ref::sink_provider_ref |
( |
Tag |
| ) |
|
|
inlineexplicitconstexprnoexcept |
Constructs a handle for a stateless sink tag.
- Template Parameters
-
| Tag | Sink tag type. |
| Traits | Specialized traits, enabled when context_type is void. |
◆ sink_provider_ref() [3/4]
template<typename Tag , typename Context , typename Traits = sink_provider_traits<Tag>, std::enable_if_t<!std::is_void_v< typename Traits::context_type > &&std::is_convertible_v< Context *, typename Traits::context_type * >, int > = 0>
| constexpr microfmt::sink_provider_ref::sink_provider_ref |
( |
Tag |
, |
|
|
Context &ctx RELOCO_LIFETIMEBOUND |
RELOCO_LIFETIME_CAPTURE_BY_THIS |
|
) |
| |
|
inlineconstexprnoexcept |
Constructs a handle for a stateful sink tag.
- Template Parameters
-
| Tag | Sink tag type. |
| Context | Concrete context type. |
| Traits | Specialized traits, enabled when context_type is non-void and Context converts to it. |
- Parameters
-
| ctx | Context object backing the writes. |
◆ sink_provider_ref() [4/4]
template<typename Tag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
| constexpr microfmt::sink_provider_ref::sink_provider_ref |
( |
Tag |
, |
|
|
Context && |
|
|
) |
| |
|
constexprdelete |
◆ as_sink()
| constexpr sink microfmt::sink_provider_ref::as_sink |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Bridges to a plain microfmt::sink, for use with format_to/vformat_to.
Valid only as long as this handle (and the context it may be bound to) stays alive; the returned sink borrows the same context pointer.
◆ can_flush()
| constexpr bool microfmt::sink_provider_ref::can_flush |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Reports whether the bound backend supports flush.
◆ flush()
| void microfmt::sink_provider_ref::flush |
( |
| ) |
const |
|
inlinenoexcept |
Flushes buffered output. A no-op when can_flush is false.
◆ operator bool()
| constexpr microfmt::sink_provider_ref::operator bool |
( |
| ) |
const |
|
inlineexplicitconstexprnoexcept |
Reports whether the handle is bound to a sink backend.
◆ write()
| void microfmt::sink_provider_ref::write |
( |
microfmt::string_view |
sv | ) |
const |
|
inlinenoexcept |
Emits a sequence of characters to the underlying sink.
If sv is empty or the handle is empty, this operation is a no-op.
- Parameters
-
| sv | String view containing characters to write. |
The documentation for this class was generated from the following file: