9#include "../reloco.hpp"
27 explicit constexpr concrete_metadata_map(span<property_entry> storage) noexcept : m_storage(storage), m_count(0) {}
37 template <
typename T>
constexpr bool set(microfmt::string_view key, value_ref<T> ref)
noexcept {
38 const T *val_ptr = ref.get();
41 for (std::size_t i = 0; i < m_count; ++i) {
42 if (m_storage[i].key == key) {
43 m_storage[i].val_ptr =
static_cast<const void *
>(val_ptr);
44 m_storage[i].print_fn = [](
const void *ptr,
const sink &out)
noexcept {
45 using DecayedT = std::decay_t<T>;
47 fmt.format(*
static_cast<const DecayedT *
>(ptr), out);
54 if (m_count < m_storage.size()) {
56 property_entry{key,
static_cast<const void *
>(val_ptr), [](
const void *ptr,
const sink &out)
noexcept {
57 using DecayedT = std::decay_t<T>;
59 fmt.format(*
static_cast<const DecayedT *
>(ptr), out);
68 [[nodiscard]]
constexpr std::size_t
size() const noexcept {
return m_count; }
69 [[nodiscard]]
constexpr std::size_t
capacity() const noexcept {
return m_storage.size(); }
70 [[nodiscard]]
constexpr bool empty() const noexcept {
return m_count == 0; }
87 state.current = m_storage.data();
89 RELOCO_BEGIN_UNSAFE_BUFFER_USAGE;
90 state.end = m_storage.data() + m_count;
94 if (s ==
nullptr || s->current >= s->end) {
101 RELOCO_END_UNSAFE_BUFFER_USAGE;
107 span<property_entry> m_storage;
108 std::size_t m_count{0};
#define MICROFMT_API_CLASS
Definition compat.hpp:181
reloco::sink sink
Type-erased, zero-allocation output sink.
Definition microfmt.hpp:46
Type-erased property entry synthesized during generation.
Definition metadata_map.hpp:24