Repository navigation
Upstream PR Queue (sorted by mergeability score) - #191
Closed
clockblocker wants to merge 54 commits into
Closed
clockblocker wants to merge 54 commits into
clockblocker wants to merge 54 commits into
Conversation
This was referenced Nov 29, 2026
clockblocker
force-pushed
the
upstream-queue
branch
2 times, most recently
from
November 29, 2026 15:25
b974204 to
fcf8d4e
Compare
…name_str_view Fixes a v0.26.1 regression (433795b) where `rfl::internal::get_type_name_str_view<T>()` returned a `std::string_view` pointing into a destroyed temporary `StringLiteral<N>`, failing constant evaluation on every call. Dispatches directly to `cpp20::get_type_name_str_view<T>()` and `cpp26::get_type_name_str_view<T>()`. Upstream PR: munich-data-engineering#804 (176/176 CI green) Downstream receipts: - NVIDIA/cuda-quantum calls `rfl::internal::get_type_name_str_view<T>()` in a constexpr context: https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Reflection.h#L27-L31 - munich-data-engineering/sqlgen carries its own copy to avoid the dangling view: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/include/sqlgen/internal/get_type_name.hpp#L13-L44
Replaces the chained `.and_then(...).or_else(...)` recursion in `rfl::OneOf::validate_impl` with an explicit check so each branch is evaluated exactly once. Previously: 1. When any non-last branch passed and a later branch failed, the inner error fell into the outer `.or_else()` handler, rejecting valid values (even printing "Expected exactly 1 out of 2 validations to pass, but 1 of them did"). 2. When multiple branches passed simultaneously, the terminal failure fell into the outer `.or_else()`, appending to a moved-from `_errors` vector and wrongly accepting invalid inputs. 3. Passing `std::move(_errors)` into `.and_then()` and then mutating `_errors` in `.or_else()` caused use-after-move and O(2^N) re-evaluation. Also removes a stray inline review comment left in `OneOf.hpp` and adds regression tests for first-branch match, multi-branch overlap, and zero-branch failure in `tests/json/test_one_of.cpp`.
…o signed integers In yyjson, non-negative integers in [0, UINT64_MAX] have subtype `YYJSON_SUBTYPE_UINT` (`uni.u64`), yet `yyjson_is_int()` matches both `UINT` and `SINT` and `yyjson_get_sint()` reads `uni.i64` directly. Values in `(INT64_MAX, UINT64_MAX]` therefore read an inactive union member and silently wrapped to negative `int64_t` (e.g. `UINT64_MAX` became `-1`), bypassing the narrow integer range check added in munich-data-engineering#746 and corrupting `rfl::Generic`. Check `yyjson_is_uint()` first with an unsigned upper-bound comparison against `std::numeric_limits<Target>::max()` before checking `yyjson_is_sint()`. Follow-up to: munich-data-engineering#746 Downstream context: mixed signed/unsigned 64-bit JSON schemas in - hudson-trading/slang-server: https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/include/Config.h#L59-L60 - openmoq/moqx: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/config/loader/ParsedConfig.h
…nich-data-engineering#375) Alternatives of an `rfl::TaggedUnion` carry mutually exclusive discriminator tags, so a valid document can match at most one branch. Marks the internal `schema::Type::AnyOf` node with a defaulted `mutually_exclusive_ = false` flag and emits `oneOf` in `src/rfl/json/to_schema.cpp` for `rfl::TaggedUnion` (including under `rfl::AddTagsToVariants`). Untagged `rfl::Variant`, `std::variant`, `std::optional`, Avro, and Cap'n Proto schemas remain unchanged. Refs: munich-data-engineering#375 (Maintainer: "you are right that oneOf is more accurate. We should change it.") Downstream receipt: - games-on-whales/wolf defines `RunnerTypes = rfl::TaggedUnion<"type", AppCMD, AppDocker>` (https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/events/events.hpp#L46) and its committed OpenAPI 3.1 spec currently emits inaccurate `anyOf` at 4 sites: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/docs/modules/dev/partials/spec.json#L939-L948
… -Wunused-parameter warnings Cleans compiler warnings across 14 public headers (+22/-18 LOC) using unnamed unused parameters (matching munich-data-engineering#582) with zero API or behavioral changes so consumers building with strict flags (`-Wall -Wextra -Werror -pedantic -Wconversion -Wsign-conversion -Wextra-semi`) get clean builds. Upstream PR: munich-data-engineering#803 Downstream receipts: - hudson-trading/slang-server suppresses reflect-cpp warnings in 4 places: https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/CMakeLists.txt#L317-L321 - games-on-whales/wolf wraps FetchContent(reflect-cpp) with `add_compile_options(-w)`: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/CMakeLists.txt#L38-L45 - munich-data-engineering/sqlgen, openmoq/moqx, and FANUC-CORPORATION/fanuc_driver all compile with `-Wall -Wextra -Wpedantic`.
clockblocker
force-pushed
the
upstream-queue
branch
from
November 29, 2026 19:59
fcf8d4e to
abc8516
Compare
clockblocker
added a commit
that referenced
this pull request
Nov 30, 2026
…te O(N*D) read deep copies Previously, rfl::generic::Reader used by-value Generic, Generic::Array, and Generic::Object as its InputVarType, InputArrayType, and InputObjectType. As a result, every traversal step (to_object, to_array, get_field_from_object, get_field_from_array, read_object, read_array) deep-copied entire nested containers and subtrees, causing O(N*D) (O(N^2) on deep trees) time and allocation complexity during rfl::from_generic / rfl::generic::read. Changes: - Switched rfl::generic::Reader::InputVarType, InputArrayType, and InputObjectType to non-owning const pointers (const Generic*, const Generic::Array*, const Generic::Object*) using std::get_if with explicit nullptr guards returning rfl::Error across all Reader methods. - Avoided mutating rfl::Object's internal cursor in get_field_from_object by scanning the const object directly and returning &v. - Updated rfl::generic::read to pass &_g to Parser::read. - Adapted rfl::parsing::Parser<generic::Reader, generic::Writer, json::Raw> in include/rfl/json/Raw.hpp to handle pointer InputVarType safely (returning an error on nullptr). - Added unit tests in tests/generic/test_generic_zero_copy.cpp covering generic::Reader zero-copy pointer identity, nullptr safety across all Reader methods, deep-80 from_generic<Generic> / from_generic<DeepNode> round-trips, and rfl::json::Raw generic::Reader integration + nullptr handling. Maintainer review notes: 1. Public API change (requires explicit maintainer sign-off per Rule #3): rfl::generic::Reader::{InputVarType, InputArrayType, InputObjectType} change from value types (Generic, Generic::Array, Generic::Object) to non-owning const pointers (const Generic*, const Generic::Array*, const Generic::Object*), matching the non-owning pointer pattern already used by rfl::toml::Reader (raw pointers) and rfl::json::Reader (pointer handles). External callers that only use rfl::from_generic / rfl::generic::read are unaffected, whereas custom Parser<generic::Reader, ...> specializations consuming generic::Reader::InputVarType directly must dereference and null-check the pointer. 2. PR dependency note (PR #191 / #36): The 5-line adaptation in include/rfl/json/Raw.hpp depends on rfl::json::Raw introduced by PR #191 (#36). If this PR is upstreamed ahead of #36, the include/rfl/json/Raw.hpp hunk and test_json_raw_with_generic_reader test are cleanly separable and can be dropped without affecting any other file. Empirical verification (Clang 23 -O2, stacked on perf/algo-c2a, D=50/100/200): - D=200 from_generic<DeepNode>: 10850 us / 61,706 allocs -> 42.0 us / 602 allocs (258x faster, 102x fewer allocs) - D=200 from_generic<Generic>: 2959 us / 22,305 allocs -> 186.7 us / 2,005 allocs (15.8x faster, 11x fewer allocs) - Linear allocation scaling confirmed at D=50/100/200: from_generic<DeepNode> (152/302/602 vs 4181/15856/61706), from_generic<Generic> (505/1005/2005 vs 1830/6155/22305). Verified with standalone header self-containment checks (including xml/Parser.hpp against pugixml) and full CTest suite (JSON, YAML, XML, Generic; 832/832 passed, 1 skipped locale test, 0 warnings) on both Clang 23.1.6 and GCC 13.4.0.
…o avoid MSVC STL4038
On MSVC in C++20 mode (/std:c++20), <expected> exists on disk so bare
`#if __has_include(<expected>)` evaluates true and emits warning
STL4038 ("The contents of <expected> are available only with C++23 or
later.") on every translation unit.
Include the C++20 standard <version> header and check
`defined(__cpp_lib_expected) && __cpp_lib_expected >= 202202L` before
including <expected>. Unlike a raw `__cplusplus >= 202302L` check,
this avoids STL4038 under MSVC C++20 while still enabling std::expected
on GCC 13 -std=c++23 (which defines __cplusplus == 202100L) and MSVC
/std:c++latest / /std:c++23preview.
…ata-engineering#565) Updates `rfl::string_to_enum` and `rfl::internal::enums::from_string` (C++20 and C++26) to accept `std::string_view` instead of `const std::string&`, replaces the exception-throwing `std::stoi` numeric fallback with allocation-free `std::from_chars` enforcing full-string consumption, and drops unused `<sstream>`. Upstream PR: munich-data-engineering#802 Closes: munich-data-engineering#565 Downstream receipts: - NVIDIA/cuda-quantum hand-loops `rfl::get_enumerator_array<E>()` just to parse a `std::string_view`: https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Reflection.h#L61-L65 - munich-data-engineering/sqlgen calls `rfl::string_to_enum` directly: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/include/sqlgen/parsing/Parser_default.hpp#L52-L57
…in headers Cuts ~40k preprocessed lines (~350 ms cold compile time per TU) from thin schema/wrapper headers without any public API changes: - Remove `<functional>` from `include/rfl/internal/cpp20/Result.hpp`. - Remove `<sstream>` from `comparisons.hpp`, `AnyOf.hpp`, `OneOf.hpp`, and `PatternValidator.hpp` (using `std::snprintf` / `std::to_string`; note that `signed char`/`unsigned char` (`int8_t`/`uint8_t`) comparison errors now format as decimal integers rather than raw ASCII characters, while plain `char` stays formatted as a character). - Remove unused `<map>` from `include/rfl/Size.hpp` and add explicit `<cstddef>`. Downstream receipts: - hudson-trading/slang-server intentionally isolates thin rfl headers in `include/Config.h` (included across 13 TUs without `<rfl/json.hpp>`): https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/include/Config.h#L9-L16 - munich-data-engineering/sqlgen includes thin headers like `<rfl/Result.hpp>` and `<rfl/PatternValidator.hpp>`: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/include/sqlgen/Result.hpp
Owner
Author
For Agents — Queue Scoring, Commit Metadata & Verification
1. Mergeability Scoring Rubric (0–100, Cutline
|
| Axis | Points | Criteria |
|---|---|---|
| S — Size & Blast Radius | 0–30 | Prod LOC, file count, header/core coupling, isolation from unrelated subsystems. |
| M — Maintainer Buy-In | 0–30 | Open upstream issue/endorsement, direct precedent PRs, alignment with maintainer priorities (compile time, zero-throw Result, backwards compat, one problem per PR). |
| D — Downstream Pain / Evidence | 0–25 | Verified real-world consumer workarounds, live bugs, or measured N=3 interleaved A/B compile-time / runtime wins. |
| R — API & Maintenance Risk | 0–15 | Backwards compatibility, header hygiene (CHECK_HEADERS), strict-warning cleanliness, future maintenance footprint. |
2. Full Queue Index (Bottom → Top)
3. Open Follow-Ups
- Rank 8 (
6b4a388a— open upstream #801): 2 optional polish nits — moveclass RFL_API ActiveNodeGuardfrompublic:toprivate:onrfl::yaml::Reader, and add a unit test covering theYAML::Mark::posbounds check on a programmaticSetTag("!")node. - Rank 48 (
da02ec6d—perf/algo-b1): 3 optional pre-upstream polish nits from Judge 7 — (1) restore SFINAE return types onVariant::visit/TaggedUnion::visitwithout breaking mutating generic lambdas, (2) cv-exact matching in non-constget_if<T>forVariant<int, const int>, (3) monitor MSVC/W4 /WXC4714onRFL_ALWAYS_INLINEindispatch.hppduring Windows CI.
4. Parked discuss/ssot Scores (Below < 65 Cutline)
| Item | Score | Why Parked on discuss/ssot |
|---|---|---|
rfl::DefaultTag<Discriminator, Tag> |
60 | No upstream issue; #455 precedent preferred std::variant<TaggedUnion<...>, Fallback>; global discriminator collision & cli/env/msgpack contract gaps. |
rfl::Int64AsString |
58 | Design questions: processor-wide vs per-field wrapper, strict bare-number rejection, LP64 vs LLP64 sizeof(long) >= 8 portability trap, validator schema interaction. |
rfl::NoDuplicateKeys |
55 | No upstream issue; 77-line hand-rolled FNV-1a table in json/Reader.hpp, unapproved Reader-vs-ObjectReader contract, toml++ mismatch. (Standalone YAML non-scalar key bugfix from #160 extracted into c7aa574c.) |
rfl::AddNullFields |
52 | Overlaps existing rfl::NoOptionals (write-side explicit nulls) and rfl::Nullable<T>; undocumented in processors.md. |
rfl::ErrorKind + Error::code() |
50 | 41 + 18 files, enum taxonomy & 28 hardcoded wire codes, implicit static V::code opt-in, changes ErrorDetail::operator==. (Standalone OneOf, noexcept, and Error::details() bugfixes extracted into e5c60531, 970f78f0, a437e427.) |
<rfl/nlohmann.hpp> |
50 | Second JSON backend adding third-party dependency across CMake/vcpkg/Conan/CI matrices. |
rfl::MaxDepth<N> |
50 | thread_local global counter (DLL/coroutine/nested-read hazards), NTTP template bloat, silent non-enforcement on recursive 3P parsers (yaml-cpp, pugixml, toml++). |
Remove dev-only vcpkg git submodule (#139) |
49 | Repo/CI workflow policy change (deletes .gitmodules + vcpkg gitlink, modifies .github/workflows/* & setup-vcpkg, introduces vcpkg-configuration.json) requiring upstream maintainer sign-off; FetchContent consumers already have GIT_SUBMODULES "" documented in b2409b10. |
rfl::Metadata<T> + SchemaName<T> / SchemaExtension<T> |
45 | Three out-of-band specialization traits, silent typo misses, new shared schema IR node (Annotated), ExtraFields on every JSON schema subtype. (Standalone isalnum UB & Avro/Cap'n Proto unwrap bugfixes extracted into 189f943d, aced7b57.) |
rfl::Alias |
45 | 31 files across case-transform processors & C++20/C++26 reflection; wrapper vs trait/processor design needs sign-off. |
DefaultIfMissing schema defaults (#396) |
41 | Maintainer flagged #396 as "tricky" and suggested rfl::Generic on #680; 971-LOC dual wrapper-walking traits + breaking output change on DefaultIfMissing. |
rfl::Nullable<T> / rfl::TriState<T> |
40 | 435-LOC new vocabulary wrappers overlapping std::optional / NoOptionals / AddNullFields. |
rfl::DefaultIfNull (#796) |
33 | Zero maintainer comments on #796, 19 prod files, 3rd wrapper-walking trait (is_nullable.hpp), #786-class sibling-field behavior cliff. |
is_safe_default_constructible |
32 | 481-line zero-caller wrapper walker + 10 public wrapper default-ctor template rewrites. |
5. Verification Receipts
upstream-queue(35ab9cfb, 53 active + 1 merged (d1f84224) = 54 commits on branch; 16 verified zero-regression algo PRs folded in, 10< 65candidates deferred torefl-cpp-workbench#36):- Standalone
CHECK_HEADERS: 463/463 non-Arrow headers PASS on Clang 23.1.6; 288/288 modified-header strict checks (-Wall -Wextra -Wextra-semi -Werror, default &-DREFLECTCPP_C_ARRAYS_OR_INHERITANCE) PASS on both Clang 23.1.6 and GCC 13.4.0. - Clang 23.1.6 Release (
-DREFLECTCPP_STRICT_WARNINGS=ON, JSON+YAML+XML): 0 warnings, 894/894 executed passed (895 total, 1 expected locale skipcli.cli_float_parsing_ignores_locale). - GCC 13.4.0 Release (
-DREFLECTCPP_STRICT_WARNINGS=ON, JSON+YAML+XML): 0 warnings, 894/894 executed passed (895 total, 1 expected locale skip). - Clang 23.1.6 & GCC 13.4.0 ASan + UBSan (
RelWithDebInfo,-DREFLECTCPP_STRICT_WARNINGS=ON, 10 formats: JSON, YAML, XML, AVRO, CAPNPROTO, FLEXBUFFERS, CBOR, UBJSON, BSON + CLI/ENV/GENERIC): 0rflwarnings, 1,217/1,217 valid tests passed, 0 unexpected failures on both compilers (exact 8 pre-existing upstream baseline ASan/UBSan items + 1 locale skip). cuda_quantum_canary(cudaq_canary_main+cudaq_canary_probe_type_name_str_view+ctest): PASS on both Clang 23.1.6 and GCC 13.4.0 with 0 leakedyyjson_*C symbols inlibcudaq_canary_plugin.so(nm -D).- Real-OSS 6-repo A/B suite (
9b382c62vs22722551, Clang 23.1.6 Release,--no-ccache --clean, quiet host): 0 regressions across all 6 consumers (sqlgen96/96 PASS:-22.1%build /-20.4%.o/-9.9%RSS;cuda-quantumPASS:-12.6%build /-18.5%RSS /-9.5%YAML.o;slang-server561/561 PASS:-3.1%build /-8.3%RSS /-2.9%.o;wolf10/10 PASS:-2.0%build /-2.3%RSS;fanuc-libs30/30 PASS:-1.7%build /-10.5%RSS /-8.9%rmibin;moqxparity:-1.1%build /-7.0%Loader.cppwall;libreflectcpp.a-19.6%to-20.6%smaller across every consumer). Full tables inrefl-cpp-workbench#33. - CMake subproject & Windows battle-testing: 5/5 Linux CMake subproject/packaging smoke tests passed (
CMP0126, externalyyjson, hidden static symbols,REFLECTCPP_JSON=OFF,find_package); Windows VS 2022 / Ninja MSVC /clang-clverification queued on updated PR head35ab9cfb. - Deferred algorithmic backlog (
refl-cpp-workbench#36): 10 candidates below the< 65Judge / zero-regression cutline excluded from bothupstream-queueanddiscuss/ssot:C2b(58),A3b-ops(57),C5c(57),C3a(56),C3b(56),A4(53),C5f(53),C5a(52),C5b(51),C5e-avro(42).
- Standalone
discuss/ssot(7e2fbf2b, 16 commits cleanly restacked on35ab9cfb):- Clang 23.1.6 Release (
-DREFLECTCPP_STRICT_WARNINGS=ON, JSON+YAML): 0 warnings, 946/946 executed passed (947 total, 1 expected locale skip). - GCC 13.4.0 Release (
-DREFLECTCPP_STRICT_WARNINGS=ON, JSON+YAML): 0 warnings, 946/946 executed passed (947 total, 1 expected locale skip).
- Clang 23.1.6 Release (
…tReader and ParserTaggedUnion Direct follow-up to munich-data-engineering#766 (`Error::details()`): - `FieldVariantReader::try_one` constructed a fresh `Error(stream.str())` instead of calling `wrap_error(stream.str(), std::string(_disc_value), std::move(_e))`, discarding nested field paths and collapsing multi-error detail vectors for externally-tagged `rfl::Variant<rfl::Field<...>, ...>`. - `ParserTaggedUnion` dropped the discriminator path segment (`_discriminator` or index `0` under `NoFieldNames`) from `Error::details()` on missing, non-string, or unknown discriminator values. Preserves `Error::what()` byte-for-byte with zero API changes. Follow-up to: munich-data-engineering#766
…uction, write, and is_empty
Previously, rfl::Generic construction, serialization, and emptiness checks
performed repeated deep copies of entire nested subtrees at every level of
recursion, causing O(N*D) (O(N^2) on deep trees) time and allocation
complexity across three hot paths:
1. Generic move construction / assignment and generic::write (Generic.hpp,
Generic.cpp, generic/write.hpp):
- Generic only provided Generic(const ReflectionType&), so Parser_default's
Generic{std::forward<NT>(reflection_val)} deep-copied every nested
Object/Array/std::string at each recursion depth.
- Added Generic(ReflectionType&&) noexcept, operator=(ReflectionType&&)
noexcept, operator=(const ReflectionType&), private
from_reflection_type(ReflectionType&&) noexcept, and a constrained rvalue
operator=(T&&) overload while preserving all existing const& overloads
(zero breaking API changes).
- Moved w.root() on return in rfl::generic::write instead of deep-copying
the entire root Generic tree.
2. Zero-copy parsing::is_empty (parsing/is_empty.hpp):
- parsing::is_empty(const Generic&) previously called _var.reflection(),
deep-copying the entire subtree just to test whether it is null.
- Short-circuited std::is_same_v<Type, Generic> directly to _var.is_null().
3. Zero-copy Generic serialization (parsing/ParserGeneric.hpp,
parsing/Parser_default.hpp, xml/Parser.hpp):
- Writing rfl::Generic previously serialized _var.reflection(), deep-copying
the full subtree at every node.
- Added ParserGeneric<R, W, ProcessorsType>::write to visit _var.variant()
by const reference directly with zero copies across standard, schemaful,
AddTagsToVariants, AddNamespacedTagsToVariants, and XML writers, while
leaving read and to_schema (including flattened anyOf and VariantsAsOneOf)
unchanged.
Empirical verification (Clang 23 -O2, deep nested Generic at D=50/100/200):
- D=200 json::read<Generic>: 2309 us / 22,306 allocs -> 122 us / 2,005 allocs (19x faster)
- D=200 json::write(Generic): 2127 us / 20,303 allocs -> 13.6 us / 2 allocs (156x faster)
- D=200 xml::write(Generic): 2530 us / 21,918 allocs -> 990 us / 1,617 allocs (2.6x faster; 5.8x at D=100)
- D=200 to_generic(DeepNode): 74 us / 2,010 allocs -> 48.4 us / 1,407 allocs
- D=200 parsing::is_empty: 15.8 us / 201 allocs -> 0.001 us / 0 allocs
- Linear allocation scaling confirmed at D=50/100/200:
json::read (505/1005/2005), json::write (2/2/2), xml::write (413/815/1617),
to_generic (357/707/1407), is_empty (0/0/0).
Verified with standalone header self-containment checks (including
xml/Parser.hpp against pugixml) and full CTest suite (JSON, YAML, XML,
Generic; 830/830 passed, 1 skipped locale test, 0 warnings) on both
Clang 23.1.6 and GCC 13.4.0.
…m_fields Replaces the O(N) linear SFINAE recursion in `rfl::internal::cpp20::num_fields` with an O(log N) exponential probe + binary search, cutting wide-struct C++20 reflection compile time and bounding template instantiation depth in +49/-4 LOC with zero public API changes. Downstream wide-struct / `num_fields` consumers: - openmoq/moqx invokes `num_fields` 27x in one TU: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/test/config/ConfigSerializerTest.cpp#L26-L128 - hudson-trading/slang-server defines 376 LSP structs up to 36 fields: https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/include/lsp/LspTypes.h#L3816-L3976 - FANUC-CORPORATION/fanuc_driver has 23-field packet structs: https://github.com/FANUC-CORPORATION/fanuc_driver/blob/da5db3f611cdc9dffe687e056c4e79bea584bf5c/fanuc_libs/rmi/include/rmi/packets.hpp#L641-L666
…WithDefault Lifts per-field parsing, placement-move, move-assign, error-recording, and extra-field helpers out of `ViewReader<..., ViewType, ...>` and `ViewReaderWithDefault<..., ViewType, ...>` into free function templates parameterized only by each field's type (never the enclosing `ViewType`), keeping linear field-name dispatch (inline for `size_ <= 4`, out-of-line for wider structs) and the compile-time positional read fast path. Parent: depends on `fix(parsing): capture input keys matching ExtraFields member name` (preserving the `is != ViewType::pos_extra_fields()` guard). Independent of `NamedTupleParser` helper isolation; wide-struct `FieldNameLookup` follows in a dedicated child commit. Judge polish applied: - Zero `[[maybe_unused]]` annotations (per munich-data-engineering#582): unmatched-name handling dispatches directly into `handle_extra_field*` / `handle_no_extra_fields_error` with only the parameters used by each branch. Follow-up to: munich-data-engineering#795, munich-data-engineering#799
…neering#731) Adds opt-in whole-enum wire-name casing transform processors (`rfl::TransformEnumNames<...>` plus aliases `EnumSnakeCaseToKebabCase`, `EnumSnakeCaseToCamelCase`, `EnumSnakeCaseToPascalCase`, `EnumCamelCaseToSnakeCase`, `EnumToLowerCase`, `EnumToUpperCase`) across read, write, `rfl::enum_to_string`, `rfl::string_to_enum`, and JSON Schema generation. Resolved wire-name tables are cached once per `(EnumType, EnumNameTransform)`. Parent: depends on `feat(enums): accept std::string_view in rfl::string_to_enum (munich-data-engineering#565)` (open upstream PR munich-data-engineering#802). Per-enum overrides/trait (`rfl::EnumNames<E>`, #106) is split into a separate child commit on top of this processor seam. Judge polish applied: - Moves non-template `apply_enum_name_transform` out-of-line into `src/rfl/TransformEnumNames.cpp` (`RFL_API`, wired via `src/reflectcpp.cpp`). - Places `enum_name_transform_v` in `include/rfl/internal/enum_name_transform_v.hpp` (mirroring `enum_names_only_v.hpp` with `std::remove_pointer_t`). - Adds `EnumCamelCaseToSnakeCase` for parity with `rfl::CamelCaseToSnakeCase` (munich-data-engineering#588). - Accepts variadic `class... Ps` on `rfl::enum_to_string` and `rfl::string_to_enum`, strips `std::remove_cvref_t<EnumType>`, and guards `config::enum_descriptions` so untransformed enums avoid static heap caches. Refs: munich-data-engineering#731 (Maintainer: "My first instinct would be a processor, but I need to give it some thought.") Downstream receipts: - NVIDIA/cuda-quantum maintains 4 hand-written `rfl::Reflector<E>` switch tables for `snake_case` -> `kebab-case` YAML enums: https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h#L27-L75 https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/v2/QuakeUnmappedProfileYaml.h#L16-L53 - openmoq/moqx duplicates `enum class QuicStack` as `rfl::Literal` + switch mapper: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/config/loader/ParsedConfig.h#L291 - munich-data-engineering/sqlgen post-processes `enum_to_string` across all 4 SQL backends: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/src/sqlgen/sqlite/to_sql.cpp#L338-L340 - games-on-whales/wolf lowercases `enum_to_string`: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/api/openapi.cpp#L92
Exposes `rfl::type_name<T>()` and `rfl::type_name_v<T>` via a thin, self-contained public header (`<rfl/type_name.hpp>`, mirroring `<rfl/num_fields.hpp>` from munich-data-engineering#451/munich-data-engineering#465) returning a compile-time `std::string_view` directly from `rfl::internal::get_type_name_str_view<T>()` without instantiating `rfl::Literal` or `rfl::internal::StringLiteral`. Parent: depends on `fix(reflection): fix dangling string_view in rfl::internal::get_type_name_str_view` (open upstream PR munich-data-engineering#804). Judge polish applied: - Drops redundant `rfl::num_fields_v<T>` (`rfl::num_fields<T>` is already a public variable template since munich-data-engineering#465). - Uses munich-data-engineering#804's `internal::get_type_name_str_view<T>()` directly to avoid `StringLiteral<N>` / `make_index_sequence<N>` bloat. Precedent: munich-data-engineering#451 Downstream receipts: - NVIDIA/cuda-quantum calls private `rfl::internal::get_type_name_str_view<T>()` with comment "Unfortunately, this has to use a private API of reflect-cpp": https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Reflection.h#L27-L31 - munich-data-engineering/sqlgen hand-rolled `sqlgen::internal::get_type_name_str_view`: https://github.com/munich-data-engineering/sqlgen/blob/265b0a174b661c5905b874f97b064aecb4cded70/include/sqlgen/internal/get_type_name.hpp#L13-L44 - games-on-whales/wolf instantiates `rfl::type_name_t<...>().str()`: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/api/api.cpp#L26
Adds `rfl::parsing::to_default_generic` so scalar and `std::optional<scalar>` default values (`bool`, plain integers, floating-point, `std::string`) construct `rfl::Generic` directly during JSON Schema emission instead of instantiating `rfl::to_generic<ProcessorsType>` / `rfl::generic::Writer`, while keeping complex types on `rfl::to_generic` with identical semantics. Parent: depends on `perf(parsing): isolate per-field helpers in NamedTupleParser, destructors, and flatten` for `build_named_tuple_field_schema`. Judge polish applied: - Drops the consumer-specific `std::vector<std::string>` special case (falls back cleanly to `rfl::to_generic`) and documents parity with `rfl::generic::Writer::to_generic`.
…itionals, and O(F) option/usage symbols
Fixes three algorithmic and compile-time scaling bottlenecks in `rfl::cli`:
1. `include/rfl/cli/Reader.hpp` (`Reader::read_object`, `Reader::is_empty`):
- Previously `read_object` stepped linearly through every entry matching
`_obj.prefix` at every nesting level, allocating a `std::set<std::string>`
and substring copies per entry (`O(N * D * (log K + D))`).
- Now uses `starts_with` (zero substring allocation), skips nested subtrees
in one jump via `lower_bound(sub_prefix + after_separator)` (where
`after_separator = static_cast<char>(path_separator + 1) == '/'`), and
deduplicates a child with an exact key via `_obj.args->contains(sub_prefix)`
rather than a per-call `std::set<std::string>`. Preserves exact visit
order, empty-prefix and empty-segment handling, and the ASCII boundary
`'-' (45) < '.' (46) < '/' (47)`.
2. `include/rfl/cli/options.hpp`:
- Previously instantiated `add_short_and_positional<NamedTupleType, _i>`
and `field_info<NamedTupleType, _i>` once per field, embedding the full
`O(F)`-length `NamedTuple` mangling `F` times (`Theta(F^2)` symbol bytes)
alongside per-field lambdas and `add_option_for_field` instantiations.
- Now parameterizes `field_info<FieldType>` and constexpr
`make_option_field_descriptor<FieldType, ProcessorsType>()` solely on the
individual field type and processors (never the enclosing `NamedTuple` or
struct), materializes one `static constexpr` descriptor table inside
`collect_options<T, ProcessorsType>`, and populates `Options` in a single
non-template `populate_options` loop. Preserves `static_assert` checks for
conflicting `Short`/`Positional`, duplicate short-name detection, and
numeric short-option detection.
3. `include/rfl/cli/usage.hpp`:
- Replaces the `Theta(F * P)` `std::find` positional scan in
`UsageCollector::add_object` with an `O(1)`
`std::unordered_set<std::string_view>` (and `std::unordered_map` with
`std::string_view` keys for `short_names_` and `meta_`).
- Replaces `add_usage_field_meta<U, NamedTupleType, ProcessorsType, _i>`
(`Theta(F^2)` symbol bytes) with a constexpr
`make_usage_field_descriptor<FieldType, ProcessorsType, bool, bool>()`
table and a single non-template `populate_usage_field_meta` helper.
Tests & empirical verification:
- Added `tests/cli/test_nested_prefixes_and_scale.cpp` covering dash/dot/slash
prefix collisions, optional prefix `is_empty` boundaries, exact-key +
descendant deduplication, `ExtraFields` / `NoExtraFields`, a 36-option wide
nested config with exact `cli::usage` verification, and 16+ positionals.
- Standalone header checks (`-std=c++20 -Wall -Wextra -Wextra-semi -Werror`,
plus `-DREFLECTCPP_C_ARRAYS_OR_INHERITANCE`) pass on Clang 23.1.6 and GCC 13.4.0.
- Full CTest suite (778 tests: 777 passed, 1 skipped locale test, 0 failed)
with `-DREFLECTCPP_STRICT_WARNINGS=ON` passes with 0 warnings on both
Clang 23.1.6 and GCC 13.4.0.
- Empirical before/after:
- 32-field CLI struct (`read` + `usage`, Clang `-O0`): targeted option/usage
symbols dropped 125 -> 6 (257,586 B -> 914 B mangled bytes, -99.65%);
all `cli::internal` mangled bytes dropped 302,278 B -> 43,493 B (-85.6%)
on Clang `-O0` and 318,754 B -> 60,592 B (-81.0%) on GCC `-O0`.
- Nested 200-option `cli::Reader::read_object` (Clang `-O2`):
depth-5x200 82.21 us -> 20.26 us (4.06x faster),
wide-10x20 54.26 us -> 20.70 us (2.62x faster),
4-level tree (256 leaves) 104.75 us -> 46.32 us (2.26x faster).
…extra_fields, and fold-based struct traits
Eliminate superlinear template instantiation chains across NamedTuple and struct/tuple trait helpers:
- find_index.hpp: replace FieldWrapper + operator| fold chains (O(N^2) Clang / O(N^3) GCC-MSVC) with a single FindIndexImpl specialization per tuple type that scans constexpr std::array<std::string_view, N> in a consteval loop. Preserves first-match semantics, empty-tuple handling, std::tuple support, and the exact static_assert diagnostic.
- NamedTuple.hpp: replace the eagerly evaluated O(N)-depth recursive find_extra_fields<>() with a non-recursive consteval loop returning -2 on a second match plus static_assert(pos_extra_fields_ != -2, ...) for the exact duplicate-ExtraFields error. Simplify both make_fields overloads to expand FieldTypes... directly with _is..., removing per-field wrap lambdas and nth_element_t lookups.
- has_fields.hpp: inspect member types in a single pass via rfl::internal::apply_to_fields and fold expressions (with a zero-flatten fast path) instead of materializing ptr_tuple_t<T> (rfl::Tuple + calculate_positions), preserving exact semantics for NamedTuple (including empty NamedTuple<> inside rfl::Flatten via `flags{sizeof...(Fields) > 0, true}`), Flatten, raw pointer members, empty structs, non-aggregates, C arrays, inheritance, and mixed-annotation diagnostics.
- has_flatten_fields.hpp & has_arrays.hpp: pattern-match rfl::Tuple<Ts...> and std::tuple<Ts...> directly with fold expressions, eliminating integer_sequence, per-element lambdas, and nth_element_t.
- is_empty.hpp: check rfl::num_fields<U> == 0 (after stripping cvref/pointers and handling NamedTuple/Tuple directly) instead of materializing ptr_tuple_t<U>.
…-transform processors Construct the renamed NamedTuple directly from its identical Values tuple via internal::from_values_tuple instead of round-tripping through NamedTuple::transform -> fields() -> apply -> make_from_tuple across all five case-transform processors: - NamedTuple.hpp: add minimal internal::from_values_tuple_t tag and explicit NamedTuple(internal::from_values_tuple_t, Values&& / const Values&) constructors on both NamedTuple<FieldTypes...> and NamedTuple<>. - internal/transform_case.hpp: add transform_case_field and transform_named_tuple_case (rvalue move and const-lvalue copy overloads) preserving xml_content, rfl::Rename, const fields, single-field nested NamedTuples, and empty NamedTuple<> behavior while enabling move-only field values. - SnakeCaseToCamelCase.hpp, SnakeCaseToPascalCase.hpp, SnakeCaseToKebabCase.hpp, CamelCaseToSnakeCase.hpp, ToAllCaps.hpp: forward auto&& _named_tuple directly to transform_named_tuple_case.
…ta-engineering#683) Adds the opt-in `rfl::IntegerBounds` processor emitting C++ integer width `minimum`/`maximum` keywords in JSON Schema (`Type::BoundedInteger` handled across JSON, Avro, and Cap'n Proto schema emitters), excluding `bool` and character types to prevent x86_64 vs ARM64 signedness drift. Judge polish applied: - Simplifies `BoundedInteger::maximum_` and `json::schema::Type::Integer::maximum` from `rfl::Variant<int64_t, uint64_t>` to `std::uint64_t`, removing `.visit()` boilerplate in Avro and Cap'n Proto schema emitters. - Strips `std::remove_cvref_t<T>` and guards `sizeof(U) <= sizeof(std::int64_t)` in `is_bounded_integer_v`, uses `inline constexpr bool`, qualifies `std::` fixed-width types, and documents `rfl::IntegerBounds` in `docs/content/processors.md`. Closes: munich-data-engineering#683 (Maintainer: "sorry, I misunderstood the issue. I think this is very possible.") Downstream receipts (bare `"type": "integer"` with zero bounds today): - openmoq/moqx: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/config.schema.json#L256-L259 - hudson-trading/slang-server: https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/clients/vscode/resources/config.schema.json#L29-L33 - games-on-whales/wolf: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/api/api.hpp#L55-L56
…ing includes in make_type_name.hpp Fixes Undefined Behavior in `rfl::parsing::replace_non_alphanumeric` where `std::isalnum(ch)` was called on a plain `char` (triggering UB and MSVC Debug CRT assertions on negative/UTF-8 bytes; sole remaining uncast `<cctype>` call in `include/` and `src/`). Also adds missing `#include <cctype>` and `#include <string>` for header self-containment.
…pr helpers `StringLiteral` is already part of reflect-cpp's public template signature surface (`rfl::Field`, `rfl::Literal`, `rfl::Rename`, `rfl::Description`, `rfl::Timestamp`, `rfl::Pattern`), forcing downstream consumers writing wrappers, partial specializations, or composed compile-time names to depend on `<rfl/internal/StringLiteral.hpp>` and `rfl::internal::StringLiteral`. - Promote `rfl::StringLiteral<N>` to a self-contained public header `<rfl/StringLiteral.hpp>` (included from `<rfl.hpp>`), preserving the Clang 21/22 C++26 `std::same_as<char>...` constructor workaround (munich-data-engineering#688), marking `string_view()`, `operator==`, and `operator!=` `noexcept`, guarding `N >= 1` via `static_assert`, using `std::size_t`, and clamping `StringLiteral(std::string_view)` to `N - 1` so `arr_[N - 1] == '\0'` always holds. - Keep `<rfl/internal/StringLiteral.hpp>` as a backwards-compatible forwarding header with `using rfl::StringLiteral;` so CTAD NTTPs, partial specializations, and existing includes remain 100% compatible. - Add `constexpr` `operator+` concatenation on `rfl::StringLiteral<N1>` + `rfl::StringLiteral<N2>` returning null-terminated `rfl::StringLiteral<N1 + N2 - 1>`. - Add `static constexpr std::string_view name_view() noexcept` on single-value `rfl::Literal<_name>`, returning a `string_view` backed by static storage duration. Addresses downstream workarounds in `munich-data-engineering/sqlgen` (41 headers still referencing `rfl::internal::StringLiteral` plus custom `GetNameFromLiteral`) and `openmoq/moqx` (`src/config/loader/StringLiteral.h`).
…tantiation contains_any/all in rfl::Literal Replace O(N) non-short-circuiting fold expressions, per-comparison std::string allocations, and O(N*M) template-instantiation folds in rfl::Literal with constexpr lookup tables and shared non-template span helpers: - Static constexpr name table (`kNames`) pointing directly into the static null-terminated StringLiteral NTTP storage, removing `rfl::Tuple<LiteralHelper<...>...>` instantiation from `Literal` itself (while keeping `LiteralHelper` intact for existing callers). - O(1), zero-allocation `name_sv()` lookup replacing the O(N) `find_name_set_if_matches` fold; `name()`/`str()`/`reflection()` construct `std::string(name_sv())`, and cross-type `Literal` and string `operator==`/`operator<=>` compare `std::string_view` directly without heap allocation. - Shared non-template `std::span` lookup helpers: early-exit linear scan for `num_fields_ <= 8`, and lazy `SortedTable` (self-contained constexpr heapsort, sorted length-first then unsigned-byte lexicographically, tie-broken by ascending original index) with branchless binary-search lower_bound for `num_fields_ > 8` preserving exact first-match semantics on duplicate entries. - O(1)-instantiation `consteval` `contains_any<Other>()`, `contains_all<Other>()`, `has_duplicates()`, and `find_value_of<_name>()` preserving exact existing semantics (including `contains_all` subset direction and empty `Literal<>`). - Shared non-template `literal_allowed_strings_vec` (with `reserve`) and `RFL_COLD` `make_unsupported_literal_error` replacing per-field fold instantiations. - Direct `kNames[_i]` indexing in `find_name_within_own_fields<_i>()` / `name_of<_value>()`, preserving `rfl::visit` and `name_view()` null-termination guarantees. - Add direct `#include "../internal/ptr_cast.hpp"` to `include/rfl/avro/Reader.hpp` and `include/rfl/capnproto/Writer.hpp` now that `Literal.hpp` no longer transitively includes `Tuple.hpp`.
…cbor/ubjson object lookup, and O(D) BSON Writer stack
Eliminates four per-format algorithmic bottlenecks across binary formats:
1. Cap'n Proto union discriminant (src/rfl/capnproto/Reader.cpp):
- Replaced the O(A) linear scan over getFields() in Reader::identify_discriminant
with Cap'n Proto's O(1) _union.val_.which() and field->getIndex().
- field->getIndex() is the field's index in getFields() (matching Writer's
getFields()[_index] and schemaful::VariantReader), including named unions
inside structs with sibling non-union fields and nested unions.
2. FlexBuffers object lookup (include/rfl/flexbuf/Reader.hpp):
- Replaced the O(M) linear scan in Reader::get_field_from_object with O(log M)
binary search directly over the sorted Keys() TypedVector using AsKey() and
std::strcmp (matching FlexBuffers EndMap ordering).
- Preserves exact distinction between an explicit null field (returned as an
empty InputVarType) and a missing key (returned as Error), and rejects
lookup keys containing embedded NUL bytes.
3. CBOR and UBJSON object lookup (include/rfl/cbor/Reader.hpp,
include/rfl/ubjson/Reader.hpp):
- Replaced the O(M) linear scan over object_range() with O(log M)
_obj.val_->find(_name) on jsoncons::json's sorted_json_object, guarded by
is_object() to preserve noexcept safety.
4. BSON Writer subdocument stack (include/rfl/bson/Writer.hpp,
src/rfl/bson/Writer.cpp):
- Changed Writer::subdocs_ from an append-only std::vector<rfl::Box<BSONType>>
(O(N) retained heap memory across wide arrays/documents) to a pointer-stable
std::deque<BSONType> stack, popping entries in end_object() immediately
after bson_append_document_end / bson_array_builder_append_document_end
completes (and on begin failure). Reduces peak stack memory from O(N) to
O(D) and eliminates per-subdocument heap allocations.
Verification:
- Standalone header checks (-std=c++20 -Wall -Wextra -Wextra-semi -Werror,
default and -DREFLECTCPP_C_ARRAYS_OR_INHERITANCE): 5/5 PASS on Clang 23.1.6
and GCC 13.4.0.
- Full test suite (JSON + Cap'n Proto + FlexBuffers + CBOR + UBJSON + BSON,
-DREFLECTCPP_STRICT_WARNINGS=ON): 0 compiler warnings on both Clang 23.1.6
and GCC 13.4.0; 100% pass (965/965 executed tests out of 966 total; 1 skipped:
cli.cli_float_parsing_ignores_locale), including all 11 new tests across the
5 test files.
- ASan + LSan + UBSan stress run passed cleanly on 10k wide + depth-30 BSON
documents.
- Empirical before/after microbenchmark (Clang 23 -O2):
* Cap'n Proto 32-alt union (50k reads, alt 31): 78.74 ms -> 31.81 ms (2.48x)
* FlexBuffers 256-key lookup (128k lookups): 126.05 ms -> 8.63 ms (14.6x)
* CBOR 256-key lookup (128k lookups): 56.77 ms -> 7.06 ms (8.05x)
* UBJSON 256-key lookup (128k lookups): 58.41 ms -> 7.10 ms (8.22x)
* BSON 50k nested structs write: 30.39 ms -> 15.57 ms (1.95x),
C++ heap allocs 100,022 -> 6 (16,670x fewer), C++ peak 13.85 MB -> 5.68 MB
…_field_names, and guaranteed O(N log N) no_duplicate_field_names Eliminate quadratic template instantiation and worst-case compile-time blowups across internal pack indexing, C++20 field-name extraction, and duplicate field-name validation: 1. nth_element_t.hpp: - Prefer C++26 pack indexing (Ts...[N]) when __cpp_pack_indexing >= 202311L in C++26+ mode (guarded against -Wc++26-extensions on Clang in C++20/23 mode). - Guard __type_pack_element with __has_builtin(__type_pack_element) instead of __clang__ so GCC 14+ also uses the O(1) builtin. - Replace the O(N) fallback for GCC <= 13 / MSVC with a shared multiple-inheritance IndexedPack<std::index_sequence<Is...>, Ts...> instantiated once per pack and queried in O(1) via ADL-suppressed select_indexed_type<I> (including <utility> only in this fallback branch). Handles cv-qualified, reference, pointer, array, void, function, incomplete, and duplicate types. 2. nth_element.hpp: - Prefer C++26 pack indexing (`_ts...[N]`) when `__cpp_pack_indexing >= 202311L` in C++26+ mode, and otherwise replace the per-target ElementWrapper<T, N, i> + operator| fold (Theta(N^2) instantiations across 0..N-1) with a shared IndexedValuePack<std::index_sequence<Is...>, Ts...> constructed via make_indexed_value_pack (keyed only by Ts...) and selected in O(1) via select_indexed_value<N>. - Preserve decayed value-return semantics (`constexpr auto nth_element(Ts&&... _ts)` without unconditional `noexcept`): non-selected arguments are bound by reference only and never copied or moved, only the selected N-th argument is copied/moved into the prvalue return (supporting move-only rvalues and safe temporary lifetime extension via `const auto&`). 3. cpp20/get_ith_field_from_fake_object.hpp & cpp20/get_field_names.hpp: - Add single-bind field_extractor<T, n>::get_ptrs / get_field_ptrs_from_fake_object returning a flat multiple-inheritance FieldPtrPack, and refactor cpp20::get_field_names to bind the fake object once per struct instead of N separate structured bindings + N nth_element calls. - Guard select_field_ptr in field_extractor<T, n>::get_ptr with `if constexpr (_i >= 0 && static_cast<std::size_t>(_i) < n)` for clean out-of-bounds static_assert diagnostics. - Preserve exact source_location/__PRETTY_FUNCTION__/__FUNCSIG__ formatting across Clang, GCC, and MSVC, handle empty structs without instantiating field_extractor<T, 0>, and keep get_ith_field_from_fake_object / get_ith_field_ptr / ith_field_is_const intact and O(1) per lookup. 4. no_duplicate_field_names.hpp: - Pattern-match TupleLike<FieldTypes...> directly (zero tuple_element_t or index_sequence instantiations, trivial O(1) specializations for 0 and 1 fields) and replace gap /= 2 Shellsort (Theta(N^2) worst case) with a self-contained constexpr heapsort (guaranteed O(N log N) worst case, shared per arity N).
…data-engineering#375) Adds opt-in `rfl::VariantsAsOneOf` so `rfl::json::to_schema` emits `oneOf` instead of `anyOf` for `rfl::Variant`, `std::variant`, and `FieldVariantParser` while preserving the backwards-compatible `anyOf` default (for overlapping alternatives) and keeping `std::optional` and `rfl::Generic` as `anyOf`. (Note: `std::expected` delegates schema generation to `rfl::Variant`, so it also emits `oneOf` under `VariantsAsOneOf`.) Parent: depends on `feat(json-schema): emit oneOf for rfl::TaggedUnion in JSON Schema (munich-data-engineering#375)` for `schema::Type::AnyOf::mutually_exclusive_` and `OneOf` emission in `src/rfl/json/to_schema.cpp`. Judge polish applied: - Replaces post-hoc `_definitions` AST mutation for `rfl::Generic` with `internal::remove_variants_as_one_of_t<ProcessorsType>`, delegating cleanly to `Parser<R, W, Generic, ...>::to_schema`. - Adds direct `<rfl/Generic.hpp>` and `<rfl/internal/variants_as_one_of_v.hpp>` includes in `Parser_default.hpp` plus multi-processor composition tests. Refs: munich-data-engineering#375 Downstream receipt: - openmoq/moqx defines 5 mutually-exclusive `rfl::Variant` config schemas currently forced to emit `anyOf` in committed `config.schema.json`: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/config.schema.json#L510-L557 https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/config.schema.json#L1188-L1203 https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/config.schema.json#L1977-L2001
…Variant, ParserRflVariant, and schemaful::VariantReader Eliminates O(K^2) member/lambda symbol instantiations, non-short-circuiting scans, intermediate pointer-variant round-trips, and unconditional happy-path error allocations across untagged variant and schemaful union parsers: - `variant_alternative_helpers.hpp`: introduces namespace-scope helpers (`record_variant_alternative_error`, `try_read_variant_alternative`, `VariantAlternativeWriter`, `VariantFieldWriter`, `SchemafulVariantAlternativeWriter`, and `variant_alternative_to_schema`) parameterized only by the active alternative type — never the enclosing `AlternativeTypes...` pack — and shared across `std::variant` and `rfl::Variant`. - `ParserVariant.hpp` & `ParserRflVariant.hpp`: switches untagged variant reads to a short-circuit `||` fold (using `std::in_place_index` for `std::variant`), dispatches writes and schema generation through the isolated namespace-scope helpers, removes the intermediate double-pointer `rfl::Variant` round-trip in `ParserVariant::write` for `rfl::Field` variants via `VariantFieldWriter`, and preserves sequential error aggregation and `VariantsAsOneOf`. - `schemaful/VariantReader.hpp`: adds an early out-of-bounds check (eliminating the unconditional 44-byte heap error string allocation on every happy-path union read), dispatches via short-circuit `||` fold, and isolates `read_union_alternative` at namespace scope. - `tests/json/test_variant_parser_dispatch.cpp`: adds focused correctness and scale tests for 16-alternative `std::variant` / `rfl::Variant` (round-trip, `std::variant<rfl::Field<...>>` write path, error aggregation, `VariantsAsOneOf`) and 16-alternative `schemaful::VariantReader` (valid indices 0..15, out-of-bounds, inner error, and empty reader). Verified: - Standalone self-containment checks on all 4 touched/added headers on Clang 23.1.6 and GCC 13.4.0 (`-std=c++20 -Wall -Wextra -Wextra-semi -Werror`, default and `-DREFLECTCPP_C_ARRAYS_OR_INHERITANCE`). - `tests/json/test_variant_parser_dispatch.cpp` compiled with `-std=c++20 -O2 -Wall -Wextra -Wextra-semi -Werror` and passed (2/2 tests) on both Clang 23.1.6 and GCC 13.4.0.
…d dispatch Parent: `perf(parsing): isolate per-field helpers in ViewReader and ViewReaderWithDefault` Adds `rfl::parsing::FieldNameLookup<rfl::Literal<_names...>>` in `include/rfl/parsing/find_field_index.hpp` and wires it into `ViewReader` and `ViewReaderWithDefault` for structs with > 4 fields: - Lookup tables are keyed solely on `ViewType::Names` (`rfl::Literal<...>`), so field wrappers like `rfl::Description` or different formats/processors share the same lookup table without duplicating instantiations. - Sequential-key cursor hint (`find_with_hint`) hits O(1) when keys arrive in declaration order; `RFL_COLD` fallback uses a linear scan for <= 8 fields and a constexpr-heapsorted binary search for > 8 fields (avoiding reliance on constexpr `std::sort` in older libc++ releases). - Keeps the small-struct (<= 4 fields) inline fold path and positional compile-time index path unchanged, and preserves exact `ExtraFields` / `NoExtraFields` / duplicate-key semantics with zero `[[maybe_unused]]` annotations. - Adds focused tests in `tests/json/test_field_name_lookup.cpp` covering small, medium (5..8), wide (> 8), out-of-order, duplicate-key, varied key lengths, and empty `Literal<>` instantiations. Benchmarks (N=3 interleaved Wave 1 vs upstream/main, Clang 23.1.6 / GCC 13.4.0): - Synthetic wide structs (`compile_stress_wide.cpp`, 32/64/128 fields): -17.0% wall / -14.9% RSS / -32.4% .o (Clang Debug); -20.0% wall / -13.0% RSS / -74.8% .o (Clang Release); -9.2% wall / -26.2% .o (GCC Debug); -7.7% wall / -31.4% .o (GCC Release). - Real OSS consumers: `slang-server` `SlangServer.cpp` -6.1% wall / -15.0% .o (Clang Debug), -8.6% wall / -8.0% RSS (GCC Release), `Config.cpp` -46.1% .o (Clang Release); `moqx` `Loader.cpp` -17.5% .o (Clang Debug), -5.4% wall (GCC Release); `fanuc-libs` `serialization.cpp` -9.9% wall / -27.1% .o (Clang Debug); `wolf` `unix_socket_server.cpp` -19.4% .o (Clang Release). - Runtime parity (`reflect-cpp-bench-json` Release): `BM_licenses` -11.1% faster GCC (+0.9% Clang), `Record2` +22.8% faster GCC (-2.3% Clang), `Record16` +11.0% faster GCC (-1.8% Clang / +0.1% FailFast), `BM_person_read` -2.5% faster Clang (+0.7% GCC).
…eader, FieldVariantParser, and ParserTaggedUnion Eliminates O(K) non-short-circuiting linear scans, O(K^2) member/lambda symbol instantiations, and `define_literal` O(K^2) template peeling across externally tagged (`FieldVariantReader`/`FieldVariantParser`) and internally tagged (`ParserTaggedUnion`) union parsers: - `find_field_index.hpp`: adds `find_in_field_name_table` (linear scan with `field_name_equals` for <= 8 entries, binary search for > 8) and non-cold `FieldNameLookup::find_direct` while keeping `FieldNameLookup::find` marked `RFL_COLD` for `ViewReader`'s out-of-order fallback. - `FieldVariantReader.hpp` & `FieldVariantParser.hpp`: dispatches field names via `FieldNameLookup::find_direct` in O(log K), short-circuits via `||` fold over lockstep `(_is, FieldTypes)...`, and isolates per-alternative read, write (`FieldVariantWriter`), and schema (`field_variant_alternative_to_schema`) helpers at namespace scope without repeating `FieldTypes...`. Preserves exact duplicate/unknown/empty error messages and nested `Error::details()` paths. - `ParserTaggedUnion.hpp`: adds `TaggedUnionTagLookup` built directly from `internal::tag_t<_discriminator, AlternativeTypes>...` (supporting single- and multi-value `rfl::Literal` tags), checks duplicate tags on the constexpr-sorted table in O(M) without `define_literal` peeling, looks up discriminators in O(log M), and isolates discriminator extraction, read, write (`TaggedUnionWriter`), and schema helpers at namespace scope. Preserves zero-copy writing when the discriminator is already a struct field, declaration-order allowed-tag lists, `NoFieldNames` handling, and nested `Error::details()` paths. - `tests/json/test_tagged_and_field_variant_dispatch.cpp`: adds focused correctness and scale tests for 24-alternative `TaggedUnion` (including multi-value `rfl::Literal` tags, `NoFieldNames`, `Error::details()`, and schema) and 24-alternative `FieldVariantReader`/`FieldVariantParser`. Verified: - Standalone self-containment checks on all 4 touched headers on Clang 23.1.6 and GCC 13.4.0 (`-std=c++20 -Wall -Wextra -Wextra-semi -Werror`, default and `-DREFLECTCPP_C_ARRAYS_OR_INHERITANCE`). - `tests/json/test_tagged_and_field_variant_dispatch.cpp` compiled with `-std=c++20 -O2 -Wall -Wextra -Wextra-semi -Werror` and passed (2/2 tests) on both Clang 23.1.6 and GCC 13.4.0.
…l isolation, stack found_ in ViewReaderWithDefault, and O(1) VectorParser::write size
Eliminates quadratic runtime/symbol scaling and per-read heap allocations across
tuple, stripped-field-name, default-value, destructor, and container parsing paths:
- TupleReader & TupleParser & call_destructors_on_tuple_where_necessary:
Replace TupleReader's non-short-circuiting comma fold over TupleType-scoped
`read_impl<0..N-1>` with a short-circuiting `||` fold over `assign_by_index`
calling namespace-scope free helpers (`read_tuple_element[_inline]`,
`placement_move_tuple_element`, `handle_missing_tuple_element`) parameterized
only on each element's type (never `TupleType`), with explicit `#include <new>`
for placement `new`. GCC 13 and Clang 23 `-O2` now lower 16-tuple dispatch to
an O(1) jump table (`notrack jmp *%rax` / `jmpq *%rdx`, single bounds check)
instead of O(N) checks per element. Also remove `TupleType`-scoped
`add_to_array`/`add_to_schema` helpers in `TupleParser` (reserving schema
vector capacity), isolate tuple element destruction into
`destroy_tuple_element_if_set<ElemType>`, and short-circuit all-trivial/empty
tuples.
- ViewReaderWithDefault:
Replace `rfl::Ref<std::array<bool, size_>> found_` (which allocated via
`std::make_shared` on every read of a `DefaultIfMissing` or `rfl::DefaultVal`
struct) with stack-allocated `mutable std::array<bool, size_> found_{}`.
Delete copy construction and copy assignment so callers cannot accidentally
copy `ViewReaderWithDefault` by value and split `found_` state. Preserves
`found()`'s `const std::array<bool, size_>&` signature, duplicate-key
tracking, and `ViewReader::assign_by_index`'s existing short-circuit `||` fold.
- ViewReaderWithStrippedFieldNames & ViewReaderWithDefaultAndStrippedFieldNames:
Remove the N-element static array of `ViewType`-scoped lambdas, member
`assign_if_field_is_field_i<0..N-1>`, and duplicated `move_to` helpers.
Reuse the isolated namespace-scope `assign_uninitialized_view_field[_inline]`
and `assign_default_view_field[_inline]` helpers from `ViewReader.hpp` /
`ViewReaderWithDefault.hpp` with short-circuiting `||` index dispatch (lowers
to O(1) jump table at `-O2`, cutting `-O0` symbols from 59 -> 6 each).
- call_destructors_where_necessary:
Remove the nested per-index inner lambda (which emitted N closure types
carrying the full `NamedTuple` at `-O0`) and fold directly over
`_view->values()` via `destroy_view_values_where_necessary`, short-circuiting
all-trivial/empty views and fixing `const` array element destruction.
- VectorParser::write:
Use O(1) `_vec.size()` when available (`std::list`, `std::set`, `std::multimap`,
`std::unordered_*`, etc.) instead of unconditionally traversing the container
with `std::distance(_vec.begin(), _vec.end())`, falling back to `std::distance`
for `std::forward_list`.
Note: `include/rfl/parsing/tabular/ArrowReader.hpp` was left untouched because
Apache Arrow headers (`<arrow/api.h>`) are not installed in this environment to
compile-test it; it still benefits automatically from `call_destructors_where_necessary`.
Empirical verification (GCC 13.4.0 & Clang 23.1.6):
- 16-tuple / 16-field scratch TU: `-O2` `.o` 386,872 -> 242,232 bytes (-37.4%);
`-O0` `.o` 2,318,024 -> 1,797,824 bytes (-22.4%); `TupleReader` `-O0` symbols
46 -> 9; `ViewReaderWithStrippedFieldNames` 59 -> 6;
`ViewReaderWithDefaultAndStrippedFieldNames` 59 -> 6;
`call_destructors_where_necessary` 35 -> 5 (1 carrying `NamedTuple`).
- Direct 16-tuple `TupleReader::read`: GCC 13 `-O2` emits `notrack jmp *%rax`
(indirect_jmps=1); Clang 23 `-O2` `assign_by_index` emits `cmpl $15` + `jmpq *%rdx`
(cmps=1, calls=0, indirect_jmps=1).
- `ViewReaderWithDefault`: `_Znwm` calls in `read_object_or_array_with_default`
dropped from 1 -> 0 for both `DefaultIfMissing` and `DefaultVal`.
- `VectorParser::write` on `std::set<int>`: extra `_Rb_tree_increment` pass
before `array_as_root` eliminated.
- Full test suite (`-DREFLECTCPP_STRICT_WARNINGS=ON`): Clang 23.1.6 776 passed /
1 expected locale skip (777 total, 0 warnings); GCC 13.4.0 776 passed / 1
expected locale skip (777 total, 0 warnings); all 8 headers pass 32/32
standalone checks on both compilers with and without
`-DREFLECT_CPP_C_ARRAYS_OR_INHERITANCE`.
…d Cap'n Proto helpers When a custom type exposes a `ReflectionType` (or `rfl::Reflector<T>::ReflType`) wrapped in `rfl::Description` or `rfl::Deprecated`, `Parser_default::make_reference` stores `Type::Description` or `Type::Deprecated` directly in `_definitions[name]`. While `type_to_avro_schema_type` and `type_to_capnproto_schema_type` already unwrapped both wrappers, three schema helper predicates did not: - `rfl::avro::is_named_type` (`src/rfl/avro/to_schema.cpp`): failed to recognize wrapped records/enums as named types, emitting duplicated anonymous `unnamed_N` definitions instead of named references. - `rfl::capnproto::is_named_type` (`include/rfl/capnproto/is_named_type.hpp`): failed to recognize wrapped structs/enums/unions/maps as named types (and was missing `#include <type_traits>` for standalone compilation). - `rfl::capnproto::string_map_to_capnproto_schema_type` (`src/rfl/capnproto/to_schema.cpp`): failed to detect wrapped `Type::Literal` values via `is_literal_type`, emitting invalid generic `Map(Enum)` instead of `ScalarMap`. Adds focused Avro and Cap'n Proto regression tests for `Description`- and `Deprecated`-wrapped custom `ReflectionType` definitions.
Parent: `feat(enums): add rfl::TransformEnumNames processors (munich-data-engineering#731)` Adds the opt-in `rfl::EnumNames<E>` specialization trait and `rfl::get_enum_wire_names<E, Ps...>()` utility so enums with non-identifier wire strings (e.g., `"c++20"`, `"nvq++"`, `"*"`), C++ keyword clashes, or enumerators outside the default reflected range can declare custom wire names across JSON, CLI, YAML, XML, Generic, and JSON Schema without duplicating enumerators as `rfl::Literal<...>`: - Supports static `overrides` (array or borrowed `overrides()` returning `std::span`, with `static_assert` rejecting dangling by-value containers) and per-enum `transform` (`EnumNameTransform` constant or custom callable). - `overrides` takes precedence over `transform`; when only `overrides` is specified, non-overridden enumerators still inherit any `rfl::TransformEnumNames<...>` processor passed to `read`/`write`/`to_schema`. - Zero-overhead `if constexpr` fast path when neither `EnumNames<E>` nor `TransformEnumNames` is active; resolved tables are cached per `(EnumType, EnumNameTransform)`. - Public `rfl::get_enum_wire_names<E, Ps...>()` accepts variadic processors, and throwing custom `transform` callbacks are caught into `rfl::Error` across both `ParserEnum::read` and direct `rfl::string_to_enum`. Open design question for upstream review: whether the trait should live at `rfl::EnumNames<E>` (matching `rfl::Reflector<T>`) or `rfl::config::enum_names<E>` (matching `rfl::config::enum_range<E>` / `rfl::config::enum_descriptions<E>`). Refs: munich-data-engineering#106 (Maintainer: "something along these lines is possible") Downstream receipts: - NVIDIA/cuda-quantum hand-written Reflector tables for non-identifier wire strings (e.g., `c++20`, `nvq++`): https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h#L27-L75 https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/v2/QuakeReferenceSemanticsProfileYaml.h#L16-L32 - openmoq/moqx custom action wire strings (`"*"` / domain verbs) & config enums: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/auth/Action.h#L24-L102 https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/config/ConfigResolver.cpp#L35-L48
…h-data-engineering#368) Adds `rfl::json::Raw` so JSON subtrees can be read and written verbatim without materializing intermediate `rfl::Generic` C++ ASTs or touching core parser headers: - Out-of-line `RFL_API` implementation in `src/rfl/json/Raw.cpp` (wired via `src/reflectcpp_json.cpp`) plus additive raw-emission methods on `rfl::json::Writer` (`yyjson_mut_rawncpy`). - `Parser<generic::Reader, generic::Writer, json::Raw>` bridging so `rfl::DefaultVal<rfl::json::Raw>`, `rfl::to_generic`, `rfl::from_generic`, and `rfl::json::to_schema` work seamlessly. - Non-JSON formats fail cleanly at compile time via `static_assert`. Judge polish applied: - Tightened unchecked string constructors to private; `Raw::from_string()` (strict RFC 8259 validated, returning `Result<Raw>`) is the safe default, with explicit `Raw::from_trusted_string()` opt-in for pre-serialized JSON. - Added standard const-only reflect-cpp accessors `get()`, `operator*()`, and `operator()()`. - Switched `Raw::from_json_obj` to `yyjson_val_write_opts(..., &err)` so serialization failures (e.g., `NaN`/`Infinity`) include `err.msg`. - Handled empty/moved-from `value_` in `Raw::to_generic()` (returning null `Generic`) and added `catch (...)` in `noexcept` `Raw::from_generic()`. - Updated `static_assert` message to mention both `rfl::json` and `rfl::Generic`. Refs: munich-data-engineering#368 Downstream receipts: - hudson-trading/slang-server double-reflects JSON-RPC params via `rfl::Generic`: https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/include/lsp/JsonRpc.h#L23-L43 https://github.com/hudson-trading/slang-server/blob/1b413a4655877a55b3f8a450c23e4ba6c2bf4267/include/lsp/JsonRpcServer.h#L53-L132 - games-on-whales/wolf stores raw Docker JSON as escaped `std::string` and re-parses `to_schema` output into `rfl::Object<rfl::Generic>`: https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/state/serialised_config.hpp#L98 https://github.com/games-on-whales/wolf/blob/ac2461f68feda41fdc7a7c8e812b9ab4b80520b7/src/moonlight-server/api/openapi.cpp#L17-L69
…t_index, and O(K) TaggedUnion::operator==
Replace quadratic/cubic template-fold dispatch in rfl::Variant and
rfl::TaggedUnion with inline multi-way switch dispatch and consteval
index/size loops (zero function-pointer trampoline tables or extra
symbols):
- include/rfl/internal/element_index.hpp: compute the first matching
cvref-stripped alternative index via a single consteval loop over
std::array<bool, sizeof...(AlternativeTypes)>.
- include/rfl/internal/variant/find_max_size.hpp: replace SizeWrapper
operator| fold instantiations with a consteval std::size_t loop over
sizeof(Types)..., handling empty packs cleanly.
- include/rfl/internal/variant/dispatch.hpp,
include/rfl/internal/variant/result_t.hpp & include/rfl/Variant.hpp:
- Replace the 12 do_visit_* non-short-circuiting fold overloads and
std::optional return boxing with SwitchDispatch (inline 1/2/3/4/8/16-way
switch specialization chain with RFL_ALWAYS_INLINE on Clang/GCC and
plain inline on MSVC to avoid C4714 under /W4 /WX, O(K/16)
instantiations, zero nth_element_t, zero address-taken trampolines).
LLVM/GCC merge the switches into a single flat jump/lookup table and
inline/constant-fold identically to baseline without emitting trampoline
symbols on small variants.
- Keep baseline non-ref-qualified Variant::visit(F&&) and
Variant::visit(F&&) const overloads (preserving lvalue-reference
forwarding for temporary/rvalue Variants and TaggedUnions) with SFINAE
invocability constraints (visit_invocable / visit_const_invocable) that
reject non-invocable, partial, mismatched-return, and value-category-
mismatched visitors cleanly without breaking mutating generic lambdas,
const-only visitors, or void/reference/non-movable return types.
- Implement rfl::get_if<T> and rfl::get_if<_i> directly via
internal::variant::Access in O(1) runtime and compile time without
visit(), with cv-exact matching first (e.g. Variant<int, const int> and
Variant<const int, int>) and safe qualification-adding fallback (e.g.
get_if<const T> on Variant<T, ...> or const Variant<T, ...>), handling
nullptr, absent types, and duplicate alternatives.
- Replace visit()+element_index in copy_from_other, move_from_other,
and destroy_if_necessary with SwitchDispatch (skipping destruction
when all alternatives are trivially destructible).
- Fix copy_from_type exception propagation (not noexcept), constrain
Variant(T&&) and operator=(T&&) with !is_lvalue_reference_v<T> &&
!is_const_v<T> so lvalues/const values use copy-and-swap
operator=(const T&), keep Variant(T&&) conditionally noexcept while
keeping Variant::operator=(T&&) noexcept, and destroy *this before
moving in Variant::swap.
- include/rfl/TaggedUnion.hpp: restore SFINAE constraints on
TaggedUnion::visit (both mutable and const overloads) and replace nested
lhs.visit(rhs.visit(...)) in TaggedUnion::operator== with an index check +
inline SwitchDispatch via Access::equals (O(K) compile time, zero extra
symbols, 5.8x faster at K=64).
- tests/generic/test_rfl_variant.cpp: cover element_index, find_max_size,
value categories (including rvalue Variant/TaggedUnion lvalue-ref source
compat), return types, SFINAE detectability & mutating generic lambdas,
move-only/non-default types, exception safety, get_if edge cases (nullptr,
duplicates, cv-exact Variant<int, const int> / Variant<const int, int> /
const Variant), 16/32-alt scale, and TaggedUnion::operator==.
…rap_in_fields, and concat_literals
Replace quadratic/cubic compile-time and runtime folds across tuple
concatenation, tuple-to-struct reconstruction, field wrapping, and
compile-time literal concatenation with single-pass O(N) algorithms:
- `internal/tuple/concat.hpp`: replace the left-fold of pairwise
`concat_two` calls (Theta(N^3) compile-time, Theta(N^2) runtime moves)
with a consteval `(outer, inner)` index table and flat indexed
reference table (`TupleRefs`), constructing the result `rfl::Tuple` in
one pack expansion with zero intermediate tuples and strictly one
move (rvalue) or one copy (all-lvalue) per element. Qualify internal
helper calls (`rfl::internal::tuple::get_ref`, `extract_concat_element`,
`concat_impl`) to prevent C++20 ADL hijacking by user element
namespaces. Also fixes the latent `const Head&` overload bug that
previously returned `TupleWrapper` instead of `rfl::Tuple`, and
handles 0/1/empty/mixed lvalue+rvalue/move-only tuples cleanly.
- `internal/move_from_tuple.hpp`: guard `unflatten_ptr_tuple` with
`has_flatten_fields<ptr_tuple_t<T>>()` and `flatten_c_arrays` with
`has_arrays<TupleType>()`, fast-pathing plain structs directly into
aggregate initialization `T{std::move(rfl::get<I>(_t))...}` without
pointer tuples or `tuple_cat`. Replace the O(N^2) `IndptrHelper` fold
with a consteval prefix-sum `std::array`, fix nested `rfl::Flatten`
pointer unwrapping in `calc_flattened_size`, and recurse
`flatten_c_arrays` into nested `rfl::Flatten` pointer tuples (covering
C-style arrays inside `rfl::Flatten` and C-arrays declared after
`rfl::Flatten`; note that the pre-existing `move_from_pointers`
limitation remains when a C-array precedes an `rfl::Flatten` field in
the same struct, as expanding a preceding C-array shifts indices in
`Pointers` relative to `ptr_tuple_t<T>`).
- `internal/wrap_in_fields.hpp` + `internal/calc_flattened_size.hpp`:
replace recursive parameter-pack peeling and `flattened_ptr_tuple_t`
materialization with a consteval `name_offsets` array and a single
non-recursive `index_sequence` expansion.
- `internal/concat_literals.hpp`: preserve the 0/1/all-single fast paths
and replace the general left-fold (which instantiated O(N)
intermediate `rfl::Literal` types with O(N^2) NTTP args on structs
containing `rfl::Flatten`) with a single-pass `(outer, inner)` index
table over flat `LiteralTypeTable` base packs, with qualified
`rfl::internal::get_indexed_literal_type` lookups to prevent ADL
hijacking.
Verified standalone header self-containment (20/20 passed, standard and
`-DREFLECT_CPP_C_ARRAYS_OR_INHERITANCE`) and full CTest suite on both
Clang 23.1.6 and GCC 13.4.0 with `-DREFLECTCPP_STRICT_WARNINGS=ON`
(0 warnings, 782 passed / 1 expected locale skip out of 783).
…er isolation, and FetchContent docs Make reflect-cpp work out of the box as a CMake subproject (FetchContent / add_subdirectory) across Linux, macOS, and Windows (VS 2022 MSBuild, Ninja MSVC, Ninja clang-cl) without mutating parent project state or tripping consumer warning/linter policies: - **Target-scoped C++ standard & top-level scoping (#157):** Compute `_REFLECTCPP_IS_TOP_LEVEL` (`CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR`), scope global `CMAKE_CXX_STANDARD` / `CMAKE_CXX_STANDARD_REQUIRED` / `CMAKE_EXPORT_COMPILE_COMMANDS` defaults, `ament_cmake` / `ament_package()`, and `CPack` to top-level builds, and declare target-scoped `target_compile_features` (`cxx_std_20` / `cxx_std_23` / `cxx_std_26` guarded on CMake >= 3.30 with `CXX_STANDARD 26` fallback on 3.25-3.29) + `CXX_STANDARD_REQUIRED ON`. - **CMake 3.20 minimum with 3.23 FILE_SET fallback (#156):** Lower `cmake_minimum_required` from 3.23 to 3.20 (supporting RHEL 8 / Ubuntu 22.04 / ROS 2 Humble), replace `PROJECT_IS_TOP_LEVEL` with `_REFLECTCPP_IS_TOP_LEVEL`, gate `FILE_SET reflectcpp_headers` on CMake >= 3.23 with an `install(DIRECTORY ...)` fallback, fix `${INCLUDE_INSTALL_DIR}` to `${CMAKE_INSTALL_INCLUDEDIR}`, and guard `$<LINK_LIBRARY:WHOLE_ARCHIVE,...>` on CMake >= 3.24 with `/WHOLEARCHIVE:` fallback. - **Subproject vcpkg/install defaults & config ordering (#142):** Default `REFLECTCPP_INSTALL` and `REFLECTCPP_USE_VCPKG` to `${_REFLECTCPP_IS_TOP_LEVEL}` (removing the unconditional top-level `REFLECTCPP_INSTALL=ON` override), preserve pre-set `CMAKE_TOOLCHAIN_FILE` (preferring explicit `-DVCPKG_ROOT`, then local `./vcpkg` submodule, then `$ENV{VCPKG_ROOT}`), replace directory-level `include_directories(PUBLIC ${jsoncons_INCLUDE_DIRS})` with target-scoped `SYSTEM PUBLIC $<BUILD_INTERFACE:...>`, and order `reflectcpp-exports.cmake` after all `find_dependency()` calls in `reflectcpp-config.cmake.in`. Keep default library naming untouched for Conan (`conanfile.py`) and existing Windows Debug consumers, documenting `-DCMAKE_DEBUG_POSTFIX=d` for multi-config single-prefix Windows installs. - **SYSTEM interface includes & warning/linter isolation (#140 Part 1):** Mark subproject consumer interface includes `SYSTEM` (unless top-level or `REFLECTCPP_STRICT_WARNINGS=ON`), propagate subproject `pugixml` includes onto `reflectcpp`'s own `SYSTEM PUBLIC $<BUILD_INTERFACE:...>` without mutating parent targets, mark bundled thirdparty & YAS includes `SYSTEM`, silence vendored `src/yyjson.c` warnings cleanly (`-w` on GNU/Clang, `/W0` under MSVC `REFLECTCPP_STRICT_WARNINGS`), clear inherited `CLANG_TIDY`/`CPPCHECK`/`IWYU` and `COMPILE_WARNING_AS_ERROR` on subproject `reflectcpp`, strip inherited MSVC `/W*`/`-W*`/`/WX*`/`-WX*` flags cleanly in local scope to eliminate D9025 spam (restoring `/W3` for `tests/` and `benchmarks/` under top-level `REFLECTCPP_STRICT_WARNINGS=ON`), use `/W4` instead of `-Wall` under `REFLECTCPP_STRICT_WARNINGS` on MSVC/clang-cl, remove redundant Release `-DNDEBUG` injection, and fix compiled-source warnings in `src/rfl/env/Writer.cpp`, `include/rfl/parsing/schema/Type.hpp`/`.cpp` (explicit out-of-line copy/move special members for C5267), and `src/rfl/json/to_schema.cpp` (C4459/C4702). - **CXX-only & MSVC-safe test/benchmark subprojects:** Add `LANGUAGES CXX` to all `tests/*/CMakeLists.txt` and `benchmarks/*/CMakeLists.txt` so `-DCMAKE_CXX_COMPILER=clang-cl` does not probe a C compiler, and guard GCC-only `-Wall -O2` `CMAKE_C_FLAGS` with `if (NOT MSVC)`. - **FetchContent quickstart & install docs:** Fix broken links and Option 5 option ordering in `README.md` and `docs/content/install.md`, and add JSON-only (`GIT_SUBMODULES ""`) and YAML FetchContent quickstart snippets. Addresses #140, #142, #156, #157 and clockblocker/refl-cpp-workbench#23.
…nd unnecessary schema AST copies
Rebased onto `upstream-queue` (`9b382c62`), which already includes explicit
out-of-line Rule-of-Five copy/move special members on `rfl::parsing::schema::Type`
and warning fixes in `src/rfl/json/to_schema.cpp` (`b6407224`). This commit
completes the schema move and O(N) insertion optimizations:
- `parsing::schema::Type` (`Type.hpp` / `Type.cpp`): adds out-of-line
`Type(VariantType&& _variant) noexcept` alongside the existing Rule-of-Five
special members so temporary `Type{std::move(...)}` construction moves
instead of deep-copying the underlying variant.
- `rfl::Object` (`Object.hpp`): adds `reserve(std::size_t)` to preallocate
backing storage without changing `sizeof(rfl::Object<T>)` or wire formats.
- O(N) unique-key schema insertions: switches `NamedTupleParser::to_schema`,
`src/rfl/json/to_schema.cpp` (`Type::Object`), and
`src/rfl/parsing/schemaful/tuple_to_object.cpp` from quadratic
`Object::operator[]` scans to `reserve(...)` + O(1) `insert(...)`, preserving
exact declaration order byte-for-byte. `NamedTupleParser::to_schema` computes
the exact non-skipped, non-`ExtraFields` count at compile time.
- Move & in-place lowering (`make.hpp`, `NamedTupleParser.hpp`,
`src/rfl/json/to_schema.cpp`): switches `parsing::schema::make`,
`NamedTupleParser::to_schema`, and JSON Schema lowering (`DefaultVal`,
`Deprecated`, `Description`, `Optional`, `Tuple`, `Object`,
`DescribedLiteral`, validation combinators, and final `JSONSchema`) to
in-place annotation mutation, `std::move`, vector `reserve`, and sorted
`emplace_hint(definitions.end(), ...)`, while preserving `b6407224`'s
shadowing and unreachable-code warning fixes.
- `tests/json/test_schema_scale.cpp`: adds scale and trait tests covering
`Object::reserve`, `parsing::schema::Type` noexcept move/constructibility,
`tuple_to_object`, wide 64-field structs, and nested variant/tagged-union/
tuple JSON schemas.
Verified:
- Standalone self-containment checks on all 4 touched headers on Clang 23.1.6
and GCC 13.4.0 (`-std=c++20 -Wall -Wextra -Wextra-semi -Werror`, default and
`-DREFLECTCPP_C_ARRAYS_OR_INHERITANCE`).
- `src/rfl/parsing/schema/Type.cpp`, `src/rfl/json/to_schema.cpp`, and
`src/rfl/parsing/schemaful/tuple_to_object.cpp` compiled cleanly on Clang
23.1.6 (`-Wall -Wextra -Wshadow -Wextra-semi -Werror`) and GCC 13.4.0
(`-Wall -Wextra -Wextra-semi -Werror`, plus `-Wshadow` clean in all touched
sources/headers).
- `tests/json/test_schema_scale.cpp` compiled with
`-std=c++20 -O2 -Wall -Wextra -Wextra-semi -Werror` and passed (5/5 tests)
on both Clang 23.1.6 and GCC 13.4.0.
…son, and add reflectcpp::headers target Improve library packaging and embedding hygiene for static/shared consumers and header-only / OBJECT-library builds: - **Bundled yyjson hidden visibility & external yyjson target (#140 Part 2):** Default-hide bundled `yyjson` symbols on static non-Windows builds (`yyjson_api=__attribute__((visibility("hidden")))` + `-fvisibility=hidden` on `src/yyjson.c`) so consumer DSOs never export `yyjson_*` symbols even with `REFLECTCPP_HIDDEN_VISIBILITY=OFF`, while keeping shared and Windows static builds untouched. Add `REFLECTCPP_USE_BUNDLED_YYJSON` and `REFLECTCPP_YYJSON_TARGET` (preserving parent normal variables under CMP0126 OLD and failing fast on misconfiguration or missing targets, including alias targets), gate `include/rfl/thirdparty` on both `REFLECTCPP_USE_BUNDLED_YYJSON` and `_REFLECTCPP_NEEDS_JSON_IMPL` so JSON-disabled builds never receive thirdparty includes, enable `POSITION_INDEPENDENT_CODE ON` by default for static subprojects when unset, and add opt-in `REFLECTCPP_HIDDEN_VISIBILITY`. - **Header-only `reflectcpp::headers` interface target (#141):** Add and export `INTERFACE` target `reflectcpp_headers` (`reflectcpp::headers`) mirroring `reflectcpp`'s C++ standard compile features, public compile definitions, SYSTEM/non-SYSTEM include directories, and conditional bundled/external dependency headers (without CMake 3.20-3.25 directory-scope `TARGET_PROPERTY` failures) without linking compiled objects, and document usage in `docs/content/install.md`. Depends on CMake PR 1 (subproject ergonomics & CMake 3.20 support). Addresses #140 and #141.
Replace superlinear recursive template instantiation chains across
remove_fields and the define_{named_tuple,literal,variant,tagged_union}
type-level builders:
- internal/IndexedTypeMap.hpp: add a collision-free O(1)-lookup indexed
type map (IndexedTypeMapEntry + select_indexed_type_map_entry) for flat
pack indexing without linear recursive peeling.
- internal/remove_fields.hpp: replace O(K * N^2) recursive field removal
with a single consteval KeepFieldsPlan and flat IndexedTypeMap expansion
(O(N)), handling 0 names, empty NamedTuple<>, unknown/duplicate names,
all-removed, and cvref-qualified NamedTuple inputs. Guard non-NamedTuple
inputs with an immediate static_assert instead of deep recursion.
- internal/define_{named_tuple,literal,variant,tagged_union}.hpp: replace
left-fold 1-by-1 peeling (O(N^2)) with O(1) fast paths (all plain Fields,
single-tag Literals, plain variant alternatives, all NamedTuples) and
4-way balanced divide-and-conquer via IndexedTypeMap (O(F log M)),
preserving exact order, duplicates, 1-level nesting, and discriminator
constraints.
Verification:
- 44/44 standalone header self-containment checks pass on Clang 23.1.6 and
GCC 13.4.0 (default & -DREFLECTCPP_C_ARRAYS_OR_INHERITANCE, -Wall -Wextra
-Wextra-semi -Werror).
- Compile-fail checks confirm immediate static_assert on non-NamedTuple
inputs to remove_fields_t (int, NamedTuple*) and discriminator mismatch
rejection in define_tagged_union_t on both Clang 23.1.6 and GCC 13.4.0.
- Full CTest suite with -DREFLECTCPP_STRICT_WARNINGS=ON: 773 passed, 1
skipped (cli locale), 0 warnings on both Clang 23.1.6 and GCC 13.4.0.
- 32-element builders + remove_fields (-fsyntax-only): GCC 2.51s / 422 MB
-> 0.91s / 177 MB (-63.7% time, -58.0% RSS); Clang 0.70s / 149 MB ->
0.65s / 124 MB (-16.6% RSS).
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.
Upstream PR Queue (
upstream-queue)Single-branch queue of self-contained, reviewable PRs for
munich-data-engineering/reflect-cpp, drip-fed 1–2 PRs at a time ontoupstream/mainin easiest-first, dependency-safe order. The queue shrinks as PRs merge upstream and grows as standalone fixes are added.Speculative proposals stay on
discuss/ssot(stacked onupstream-queue); standalone bugfixes found there drop into this queue. Landable CMake onboarding PRs live here; dev-onlyvcpkgsubmodule removal stays parked ondiscuss/ssot.Highlights
Compile-time, binary size & runtime
Full 54-commit queue (
290bdb24b7d6→35ab9cfb1eff) vs.main(single sequential end-to-end run, Linux Clang 23.1.6 & GCC 13.4.0 Release,ccacheoff — captured run results in refl-cpp-workbench#34):N=3interleaved surgical TUs; 0 regressions across all 6 consumers):sqlgen(96/96 PASS):63.2 → 47.5 s), peak RSS -9.1%.o-20.7% (330.1 → 261.8 MiB),sqlgen-sqlite-testsbinary -14.5%cuda-quantum(Target@90e4aa08b, CTest PASS):12.4 → 10.8 s), peak RSS -20.6%.o-23.3% (TargetConfigSchema.cpp-23.6% wall / -28.5%.o),libCUDAQTargetCatalog.a-16.5%slang-server(561/561 PASS):306.8 → 292.9 s), peak RSS -12.6% (2262 → 1978 MiB).o-2.5%,slang-serverbinary -4.2% (Config.cpp.o-47.1%,SlangServer.cpp-8.8% wall)wolf(10/10 PASS),fanuc-libs(30/30 PASS),moqx(218/220*):wolf: full build -1.5%, peak RSS -3.5%,wolftests-4.9% (unix_socket_server.cpp.o-22.8%)fanuc-libs: full build at parity (+0.7%), peak RSS -17.5%,rmibinary -5.1% (serialization.cpp-25.9% wall / -24.9% RSS)moqx: full build & RSS at parity (+0.1%/0.0%),Loader.cpp-6.0% wall / -7.6% RSSlibreflectcpp.a: -14.0% to -17.6% (1.57 → 1.30 MBJSON builds) across all JSON/YAML/TOML consumerscompile_stress_wide.cpp, 32–128 fields,N=3interleaved):±3.3%noise floor): wall -43.9% (11.86 → 6.66 s), peak RSS -46.4%,.o-74.9% (4.44 → 1.12 MB), linked binary -77.6%±1.8%noise floor): wall -74.5% (40.92 → 10.43 s), peak RSS -79.8% (3,353 → 678 MiB),.o-33.8%clang++ -E): -13.8k to -19.0k fewer preprocessed lines (-18.6% to -23.2%) onResult.hpp,comparisons.hpp,AnyOf.hpp,OneOf.hpp, andSize.hppN=3interleaved medians):Record2+23.8% MB/s (Record2<true>+18.7%),Record16+14.9%,citm_read+9.7%,BM_licenses-7.7% latencyBM_canada_reflect_cpp-4.5% latency;Record2/Record16/write benchmarks at parity (within±3.3%noise floor)-O3):json::write(rfl::Generic)depth-100 66.9x (read6.0x), FlexBuffers/CBOR/UBJSON 256-key lookup 10.4x–22.5x,strings::replace_all/split21.7x–22.5x,TaggedUnion::operator==(64 alts) 16.9x (read2.5x),TupleReader(64f) 8.0x,json::to_schema(128f) 6.3x,bson::write(10k nested) 1.6x*
moqxhas 2 intentional test diffs from upstream bugfixes: negative-to-unsigned YAML rejection andTaggedUniononeOf/ flattenedanyOfJSON Schema.New features & ergonomics
rfl::json::Raw): read/emit raw JSON subtrees withoutrfl::Generictrees or double-escaping.rfl::cli::usage): generate--helptext directly from anyrfl::cli::readstruct.rfl::TransformEnumNames), per-enum overrides (rfl::EnumNames<E>), and zero-allocationstd::string_viewinrfl::string_to_enum.rfl::type_name<T>andrfl::StringLiteral(with+andLiteral::name_view()), avoidingrfl::internal::.rfl::json::read_*/write_*constants replacingYYJSON_*macros.oneOfforrfl::TaggedUnion, flattenedanyOffor optional variants, plusrfl::IntegerBoundsandrfl::VariantsAsOneOf.CMake & packaging
SYSTEMincludes, and isolated warnings, linters, install, and CPack underFetchContent/add_subdirectory.yyjsonin static builds (0leakedyyjson_*in consumer DSOs), supports externalyyjson, exportsreflectcpp::headers, and shipsTHIRD_PARTY_NOTICES.md.-Wall -Wextra -Werror -Wsign-conversion -Wextra-semi, plus MSVC/std:c++20(STL4038) andC4996fixes.Parked Work
14 design-heavy proposals needing upstream maintainer sign-off remain restacked on
discuss/ssot— see#208(Discussion Queue Overview (discuss/ssot)) and the For Agents comment below.