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

Compile-time Entry NTTP and the runtime-view TagValMetadata struct. More...

#include <commons/color.hpp>
#include <commons/fixed_string.hpp>
#include <commons/icon.hpp>
#include <optional>
#include <string_view>
+ Include dependency graph for entry.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagval::Entry< Owner, Code, Label, Icon, Color >
 Compile-time entry. More...
 
struct  tagval::TagValMetadata
 Runtime view of an entry's metadata. More...
 

Namespaces

namespace  tagval
 

Functions

template<typename E >
constexpr std::string_view tagval::label_or_code () noexcept
 If the user declared an empty label, fall back to the code so that label() never returns an empty string for a valid entry.
 
template<typename E >
constexpr TagValMetadata tagval::metadata_of () noexcept
 

Variables

template<typename E >
constexpr TagValMetadata tagval::metadata_v = metadata_of<E>()
 Pinned, per-entry TagValMetadata constant.
 

Detailed Description

Compile-time Entry NTTP and the runtime-view TagValMetadata struct.

Each user-declared struct Active : tagval::Entry<Status, "active", ...> {} is a distinct type. Per-kind storage (a static constexpr array for ClosedEnded, a Meyers-singleton vector for OpenEnded) materializes a TagValMetadata for every entry; handles store the address of the matching record inside that storage. Pointer equality on that address is value equality.