Repository navigation
Avoid instantiating named_tuple_t<T> in HasDefaultVal via apply_to_fields - #126
Open
clockblocker wants to merge 1 commit into
Open
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
clockblocker
force-pushed
the
perf-apply-to-fields-has-default-val
branch
from
December 2, 2026 08:57
638a565 to
efde79f
Compare
This was referenced Dec 2, 2026
…tVal Adds `rfl::internal::apply_to_fields` (C++20 and C++26) to invoke a visitor directly on structured-binding field references without materializing `rfl::Tuple` or `rfl::NamedTuple`, and rewrites `HasDefaultVal<T>` on top of it (dropping `#include "../NamedTuple.hpp"` in favor of a forward declaration and fixing a raw-pointer false positive). Judge polish applied: - Qualifies `rfl::internal::apply_to_fields(...)` and `cpp20::apply_to_fields_impl<...>` to prevent ADL ambiguity when user namespaces define `apply_to_fields`. - Guards `HasDefaultVal<T>`'s `requires` clause with `!is_named_tuple_spec<T>::value` before `std::is_aggregate_v<T>` so forward-declared `NamedTuple<...>` stays well-formed without including `NamedTuple.hpp`. - Uses `is_default_val` in `HasDefaultVal<NamedTuple<Fields...>>` so it strips one pointer level as documented (instead of two), and renames function template `has_default_val_type_v` to `has_default_val_field`. Downstream validation: - Verified 0 warnings and 96/96 PASS on munich-data-engineering/sqlgen (metaprogramming canary) plus slang-server, moqx, fanuc-libs, and wolf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related munich-data-engineering/reflect-cpp#799 · Related munich-data-engineering/reflect-cpp#641
Problem
Checking whether an aggregate struct contains an
rfl::DefaultValfield instantiatednamed_tuple_t<T>, computed every field name string, and built a fullNamedTupletype.The trait only inspects field types and never uses field names, so all of that template work is wasted on every reflected aggregate.
Summary
apply_to_fieldshelper (C++20 and C++26) that passes structured-binding references directly to a visitor without materializing a tuple orNamedTuple.#include "../NamedTuple.hpp"fromhas_default_val_v.hppvia forward declaration and fixes a raw-pointer false positive.For Agents
upstream-queue(ba007eed) · Score84/100(S=28,M=28,D=15,R=13) ·+89/-21(4f)queue-tests/json/test_has_default_val.cpp,queue-tests/json_c_arrays_and_inheritance/test_c_array_has_default_val.cpp