Repository navigation
Backlog
Labels
enhancementNew feature or requestknown-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposneeds-triageMaintainer needs to evaluate this issue
Description
Part of #138
Popularity: 1/7 corpus consumers (cuda-quantum)
Problem
In upstream reflect-cpp (v0.25.0):
rfl::enum_to_string(E)allocates and returns astd::stringinstead of returning a non-allocatingstd::string_view.rfl::string_to_enum<E>(const std::string&)requires an owningstd::stringargument and returnsrfl::Result<E>(with heap-allocated error strings on miss) rather than acceptingstd::string_viewand offering a lightweightstd::optional<E>lookup.
Consumers writing hot-path or FFI/Python binding casters that only need non-allocating name <-> enumerator lookups end up writing their own linear loops over rfl::get_enumerator_array<E>().
Observed Downstream Workaround
NVIDIA/cuda-quantum (90e4aa08)
cudaq/lib/Target/Reflection.h#L53-L68: hand-rollsenumName(std::string_view) andenumFromName(std::optional<E>) by iteratingrfl::get_enumerator_array<E>():/// The name of the enumerator `value`. template <typename E> std::string_view enumName(E value) { for (auto [name, enumerator] : rfl::get_enumerator_array<E>()) if (enumerator == value) return name; return {}; } /// The enumerator of `E` called `name`. template <typename E> std::optional<E> enumFromName(std::string_view name) { for (auto [enumeratorName, enumerator] : rfl::get_enumerator_array<E>()) if (enumeratorName == name) return enumerator; return std::nullopt; }
Related Fork Work
- Fork PR Accept std::string_view in rfl::string_to_enum #76 (Accept
std::string_viewinrfl::string_to_enum, live upstream as#802, tracked in Map (Lane 1): Core Hygiene & Perf #85) — removes thestd::stringallocation on the input parameter ofrfl::string_to_enum. - Still open for ergonomics: a non-allocating
std::string_viewenum-to-name helper (enum_to_string_view/constexprlookup) and/orstd::optional<E>lookup withoutrfl::Errorstring construction.
Upstream Overlap
- string_to_enum does not support std::string_view munich-data-engineering/reflect-cpp#565 (open, partial) — Requests
std::string_viewsupport inrfl::string_to_enum(maintainer replied "yes, I think that should be possible"). - Accept std::string_view in rfl::string_to_enum munich-data-engineering/reflect-cpp#802 (open PR, partial; closes
#565) — Updatesrfl::string_to_enumto acceptstd::string_viewwith zero-allocationstd::from_chars/string_viewslicing. - Unfiled upstream: Zero-allocation
std::string_viewenum-to-name helper (enum_to_string_view) andstd::optional<E>lookup withoutrfl::Errorallocation.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestknown-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposneeds-triageMaintainer needs to evaluate this issue
Activity
clockblocker commentedon Nov 29, 2026
Tracking & PR Cross-Reference
Status: Mostly addressed in
upstream-queue(Draft PR #191).munich-data-engineering/reflect-cpp#802(closes upstreammunich-data-engineering/reflect-cpp#565) / fork PR Accept std::string_view in rfl::string_to_enum #76 (Acceptstd::string_viewinrfl::string_to_enum) → Rank Accept repeated list options and remaining positional arguments in rfl::cli #6 in Draft PR Upstream PR Queue (sorted by mergeability score) #191 (commit080b91ac, score 92/100).enum_to_string_view(vsstd::string rfl::enum_to_string) and astd::optional<E>lookup helper (avoiding heap-allocatedrfl::Erroron miss) are not yet covered.