tagval 0.2.0
Modern C++23 header-only library of tagged values (open/closed enumerations with metadata)
Loading...
Searching...
No Matches
tagval::KindRegistry Class Reference

Program-wide index of every kind that opted in via TAGVAL_REGISTER_KIND. More...

#include <kind_registry.hpp>

Static Public Member Functions

template<typename T >
requires detail::TagValKind<T>
static void register_kind ()
 Register a kind.
 
static std::span< const KindViewall () noexcept
 All registered kinds, in registration order.
 
static auto all_closed () noexcept
 Lazy filter view over the registered kinds that selects closed-ended kinds only.
 
static auto all_open () noexcept
 Lazy filter view over the registered kinds that selects open-ended kinds only.
 
static const KindViewfind (const std::string_view kind_id) noexcept
 Find a kind by id.
 

Detailed Description

Program-wide index of every kind that opted in via TAGVAL_REGISTER_KIND.

All methods are noexcept readers except register_kind, which mutates shared storage and is only safe to call during static-init.

Member Function Documentation

◆ register_kind()

template<typename T >
requires detail::TagValKind<T>
static void tagval::KindRegistry::register_kind ( )
inlinestatic

Register a kind.

Idempotent on kind_id — calling twice (e.g. the macro appears in two TUs that both end up in the binary) is a no-op on the second call.

◆ all()

static std::span< const KindView > tagval::KindRegistry::all ( )
inlinestaticnoexcept

All registered kinds, in registration order.

◆ all_closed()

static auto tagval::KindRegistry::all_closed ( )
inlinestaticnoexcept

Lazy filter view over the registered kinds that selects closed-ended kinds only.

The result is a view; iterating it after a static-init registration that happened later in program startup is fine, since the view re-reads the underlying storage on each iteration.

◆ all_open()

static auto tagval::KindRegistry::all_open ( )
inlinestaticnoexcept

Lazy filter view over the registered kinds that selects open-ended kinds only.

◆ find()

static const KindView * tagval::KindRegistry::find ( const std::string_view  kind_id)
inlinestaticnoexcept

Find a kind by id.

Returns nullptr if no kind with that id has been registered.


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