Repository navigation
Discussion Queue Overview (discuss/ssot) - #208
Draft
clockblocker wants to merge 49 commits into
Draft
clockblocker wants to merge 49 commits into
clockblocker wants to merge 49 commits into
Conversation
Owner
Author
For Agents —
|
| PR | Branch | Base | Isolated SHA | discuss/ssot SHA |
Score | Legacy Fork PR | Prod LOC |
|---|---|---|---|---|---|---|---|
| #192 | discuss/default-tag |
upstream-queue |
c9ac3a01 |
ca180016 |
60 | #129 |
+173/-14 (4f) |
| #193 | discuss/int64-as-string |
upstream-queue |
05d7ae15 |
2d4cc8c7 |
58 | #134 |
+114/-7 (7f) |
| #194 | discuss/no-duplicate-keys |
upstream-queue |
ebf20b62 |
ebf20b62 |
55 | #128 |
+319/-18 (10f) |
| #195 | discuss/add-null-fields |
upstream-queue |
24519e36 |
57e79d3b |
52 | #122 (split) |
+81/-1 (4f) |
| #196 | discuss/error-kind |
upstream-queue |
9fe09b9c |
eb26e637 |
50 | #70 |
+345/-115 (38f) |
| #197 | discuss/nlohmann-adapter |
upstream-queue |
c76ea514 |
c14ad37b |
50 | #69 |
+1106/-4 (13f) |
| #198 | discuss/max-depth |
upstream-queue |
478c7268 |
f8a28f77 |
50 | #130 |
+288/-47 (9f) |
| #199 | discuss/remove-vcpkg-submodule |
upstream-queue |
f8bbf33d |
4d1285a7 |
49 | — (fork #139) |
+23/-11 (10f) |
| #200 | discuss/metadata |
upstream-queue |
e562074b |
b73f3eac |
45 | #119 |
+339/-12 (8f) |
| #201 | discuss/field-alias |
upstream-queue |
a651eb24 |
18efb844 |
45 | #83 |
+813/-30 (23f) |
| #205 | discuss/error-code |
discuss/error-kind |
058f5225 |
f42f94f5 |
45 | #120 |
+528/-33 (15f) |
| #206 | discuss/default-if-missing-schema |
discuss/safe-default-constructible |
761493c2 |
a2126e13 |
41 | #78 |
+614/-56 (4f) |
| #202 | discuss/schema-name-extension |
upstream-queue |
f9df5c30 |
189f13f8 |
40 | #121 |
+277/-16 (12f) |
| #203 | discuss/nullable-tristate |
upstream-queue |
05c956ee |
6f861b64 |
40 | #122 |
+679/-7 (11f) |
| #207 | discuss/default-if-null |
discuss/safe-default-constructible |
f52189e3 |
dbf879ab |
33 | #79 |
+671/-38 (19f) |
| #204 | discuss/safe-default-constructible |
upstream-queue |
f3a6d1d6 |
f84d04ab |
32 | — (split from #78/#79) |
+504/-1 (11f) |
Cross-PR Interop Present Only on discuss/ssot (Decoupled on Isolated PRs)
- #193 (
int64-as-string) & #198 (max-depth) × #196 (error-kind):discuss/ssottags parse/depth errors withErrorKind::invalid_value/ErrorKind::syntax_error; isolated PRs use plainrfl::Error. - #196 (
error-kind) × #204 (safe-default-constructible):discuss/ssottags theis_safe_default_constructiblemissing-field branch inNamedTupleParser.hpp. - #203 (
nullable-tristate) × #207 (default-if-null), #195 (add-null-fields), #206 (default-if-missing-schema):discuss/ssotwiresis_nullable_optional<Nullable/TriState>, skipsforce_emit_nullfor omittedTriState, and guardsDefaultIfMissingschema defaults onTriState. (Note: the 7-fieldhas_annotationsstructured-binding update insrc/rfl/json/to_schema.cppwas moved cleanly into #202discuss/schema-name-extensionso #202 compiles standalone.) - #201 (
field-alias) × #203 (nullable-tristate), #207 (default-if-null), #195 (add-null-fields):discuss/ssotpeelsAliasinsidefield_aliases_impl<Nullable/TriState>,is_nullable.hpp, andcontains_skip_serialization_wrapper/contains_tri_state_wrapper.
Follow-Up Nits Caught During Split & Verification
- Fixed on isolated #200 (
e562074b):tests/avro/test_metadata.cpp:62-63previously checked quoted"InnerMeta"/"OuterMeta"without thetest_avro_metadata__namespace prefix emitted bymake_type_name<T>(). Updated ondiscuss/metadatato checkInnerMeta"/OuterMeta"+ no"unnamed_; port that 3-line test fix back intodiscuss/ssoton its next rebase. - MSVC
/std:c++20 /WXnote:is_safe_default_constructible.hpp(#204),can_write_generic.hpp(#206), andis_nullable.hpp(#207) still use bare#if __has_include(<expected>); align withupstream-queuecommit4879f7e2(<version>+__cpp_lib_expected >= 202202L) before promoting any of those three.
Verification Receipts
- Combined
discuss/ssotstack (4d1285a7):- Clang 23.1.6 (
-DREFLECTCPP_STRICT_WARNINGS=ON,JSON+YAML): 0 warnings, 877/877 tests passed (1 Linux locale skip). - GCC 13.4.0 (
-DREFLECTCPP_STRICT_WARNINGS=ON,JSON+YAML): 0 warnings, 877/877 tests passed (1 Linux locale skip).
- Clang 23.1.6 (
- Isolated
discuss/*branches (#192–#207):- 16/16 compiled and passed independently on Clang 23.1.6 (
-DREFLECTCPP_STRICT_WARNINGS=ON, 0 library warnings, standalone public headers clean, including Avro, Cap'n Proto, YAML, JSON,nlohmann::json, and compile-fail tests).
- 16/16 compiled and passed independently on Clang 23.1.6 (
clockblocker
force-pushed
the
discuss/ssot
branch
from
November 30, 2026 10:47
4d1285a to
7e2fbf2
Compare
clockblocker
force-pushed
the
upstream-queue
branch
2 times, most recently
from
November 30, 2026 20:35
35ab9cf to
f0bcaca
Compare
clockblocker
force-pushed
the
discuss/ssot
branch
from
November 30, 2026 20:35
7e2fbf2 to
de6a948
Compare
clockblocker
force-pushed
the
upstream-queue
branch
2 times, most recently
from
December 1, 2026 05:54
2c02c24 to
04e6f0a
Compare
clockblocker
force-pushed
the
discuss/ssot
branch
2 times, most recently
from
December 1, 2026 06:08
6bac212 to
1be0c82
Compare
clockblocker
force-pushed
the
upstream-queue
branch
from
December 1, 2026 06:09
04e6f0a to
7bfe63c
Compare
…tors, and flatten Moves per-field serialization, schema building, missing-field handling, and destructor helpers out of `NamedTupleParser<..., FieldTypes...>` into free templates parameterized only on each field's type (never the enclosing `NamedTuple` pack), and skips instantiating destructors for trivially destructible fields/arrays. Eliminates O(N^2) symbol-table and DWARF growth on wide structs with zero public API changes. Split from parser-symbol-isolation (#118) into an independent, reviewable chunk (no lookup algorithm changes; `to_default_generic` fast-path and `ViewReader` isolation follow in separate commits). Follow-up to: munich-data-engineering#795, munich-data-engineering#799 Downstream receipts (combined Wave 1 N=3 interleaved medians vs main): - hudson-trading/slang-server (`SlangServer.cpp` Debug): -15.0% `.o` Clang, -9.6% GCC, -6.1% wall - openmoq/moqx (`Loader.cpp` Debug): -17.5% `.o` Clang, -13.5% GCC, -4.4% wall - FANUC-CORPORATION/fanuc_driver (`serialization.cpp` Debug): -27.1% `.o` Clang, -9.9% wall - games-on-whales/wolf (`unix_socket_server.cpp` Release): -19.4% `.o` Clang
…ple lambdas Root cause: - rfl::internal::tuple::calculate_positions() previously built Positions<last, is...> via a left-fold of operator+ over PositionWrapper<T>, instantiating N distinct class/operator templates carrying Theta(N^2) NTTP arguments on every rfl::Tuple, NamedTuple, and View. - rfl::Tuple's constructors, destructor, equality, and three-way comparison each instantiated per-index generic lambdas (copy_one, move_one, destroy_one, is_same, compare), per-index pos<_i>() helpers, and repeated nth_element_t<_i, Types...> lookups, creating Theta(N^2) symbol-name and DWARF bloat. Fix: - Rewrite calculate_positions<Types...>() as a single O(N) consteval loop returning std::array<std::size_t, sizeof...(Types) + 1> with identical alignment/padding offsets (including empty pack handling and LLP64-safe size_t arithmetic). - Expand Types... (and OtherTypes...) directly in lockstep with std::index_sequence<_is...> using positions_[_is] across copy, move, destroy, operator==, and operator<=>, eliminating all per-index lambdas, pos<_i>(), and internal nth_element_t instantiations. - Add C++20 constrained destructors so rfl::Tuple is trivially destructible whenever all elements are trivially destructible (e.g. to_view() pointer tuples), and dispatch non-trivial element destruction to a namespace-scope rfl::internal::tuple::destroy_element<T>() helper decoupled from the enclosing Tuple type. - Roll back already-constructed prefix elements if a mid-tuple copy constructor throws (guarded for -fno-exceptions and skipped at compile time for single-element, nothrow-copy, or trivially-destructible tuples). - Add unit tests in tests/generic/test_tuple.cpp covering empty/single/wide (64-element) tuples, mixed/over-aligned layouts, move-only and const elements, cross-type == and <=>, ctor/dtor counts, and exception rollback. Verification: - Standalone header syntax checks (-std=c++20 -Wall -Wextra -Wextra-semi -Wpedantic -Wshadow -Wconversion -Wsign-conversion -Werror, plus -DREFLECTCPP_C_ARRAYS_OR_INHERITANCE and -fno-exceptions): 0 warnings on Clang 23.1.6 and GCC 13.4.0. - Full CMake/CTest suite (JSON + YAML, REFLECTCPP_STRICT_WARNINGS=ON): Clang 23.1.6: 778/778 passed (1 locale test skipped), 0 warnings. GCC 13.4.0: 778/778 passed (1 locale test skipped), 0 warnings. - N=64 Tuple micro-check (two 64-element tuples, trivial + std::string): Clang 23 -O2 -g: 2310 ms -> 444 ms (5.2x), .o 1,076,960 B -> 262,152 B (-75.7%) Clang 23 -O0 -g: 988 ms -> 385 ms (2.6x), .o 2,389,072 B -> 579,728 B (-75.7%), symbols 1215 -> 384 (Tuple members 282 -> 29) GCC 13 -O2: 5098 ms -> 706 ms (7.2x), .o 38,672 B -> 29,840 B (-22.8%) GCC 13 -O0 -g: 3438 ms -> 729 ms (4.7x), .o 3,761,704 B -> 787,760 B (-79.1%), symbols 1817 -> 477 (Tuple members 678 -> 40, lambdas 388 -> 0)
…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.
…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
…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).
…nd YAML Add an opt-in rfl::NoDuplicateKeys processor that rejects repeated keys in JSON and YAML objects/mappings across structs, maps, rfl::Object, rfl::Generic, rfl::FieldVariant, and rfl::TaggedUnion while preserving backwards-compatible default behavior. - Avoid pulling <unordered_set> into core Reader headers: json::Reader uses a compact stack-buffered SeenStringViews tracker (<=16 keys zero-alloc, open-addressed FNV-1a table beyond) and yaml::Reader reuses <unordered_map>. - Remove misleading noexcept on MapReader::add_error. - Fail at compile time via static_assert when used with unsupported readers.
…ocessor Supplies a compile-time-validated default discriminator tag when deserializing an rfl::TaggedUnion whose discriminator key is absent from the input object. Real-world downstream consumer: NVIDIA/cuda-quantum (cudaq/lib/Target/Yaml/TargetConfigSchema.cpp:36-41) currently bypasses rfl::yaml::read(string), loads a raw YAML::Node via yaml-cpp, mutates node["version"] = "1", and passes rfl::yaml::InputVarType(node) to rfl::yaml::read just to default unversioned TargetConfigSchema files to v1. Why not std::variant<TaggedUnion<...>, FallbackType>? 1. Swallows bad tags: std::variant<TaggedUnion<"version", V1, V2>, V1> falls back to V1 even when "version" is explicitly invalid (e.g. "99" or 123); DefaultTag falls back only when the discriminator key is absent. 2. Asymmetric writes: holding V1 in the outer variant omits "version": "1" on write, whereas DefaultTag always deserializes into the TaggedUnion and writes the explicit discriminator. 3. Degraded diagnostics: untagged std::variant loses tagged-union error messages. 4. Ergonomics: callers must handle V1 twice across nested variants. DefaultTag is a read-side fallback (writing always emits the discriminator and to_schema keeps it required) with zero runtime overhead when unused.
…d constrain wrapper default ctors - Add include/rfl/internal/is_safe_default_constructible.hpp using Wave 1C rfl::internal::apply_to_fields and forward declarations for rfl:: wrappers (dropping named_tuple_t.hpp and ~20 wrapper header includes). - Constrain default constructors on Attribute, Commented, DefaultVal, Deprecated, Description, Rename, Tuple, Validator, Variant, and Skip using a unified deferred template-constrained form so nested structs with deferred default member initializers (e.g. rfl::json::schema::Type) remain default-constructible while non-default-constructible wrapped types fail std::is_default_constructible_v cleanly. - Add tests/generic/test_is_safe_default_constructible.cpp.
…nich-data-engineering#396) - Extract can_write_generic and unwrap_default_value into include/rfl/internal/can_write_generic.hpp using Wave 1C apply_to_fields and forward declarations for rfl:: wrappers (avoiding <functional>, named_tuple_t.hpp, and 40+ transitive header includes in NamedTupleParser.hpp); keep std::reference_wrapper specialization in ParserReferenceWrapper.hpp. - Reuse Wave 1D build_named_tuple_field_schema and to_default_generic in NamedTupleParser.hpp (preserving uint64_t > INT64_MAX guard and Processors<Ps...> unpacking). - Gate DefaultIfMissing schema default construction in Parser_default.hpp on is_safe_default_constructible_v with try/catch (...) fallback. - Update docs/content/json_schema.md and tests/json/test_json_schema4.cpp, and add focused tests in tests/json/test_json_schema_default_if_missing.cpp.
…ngineering#796) - Add rfl::DefaultIfNull processor (include/rfl/DefaultIfNull.hpp, include/rfl/internal/default_if_null_v.hpp, include/rfl.hpp). - Add exception-safe default_construct() (with catch (...) in noexcept boundary) and forward-declared, zero-wrapper-bloat is_nullable_v<T> (in rfl::internal namespace, handling custom-deleter std::unique_ptr and explicit rfl::Generic). - Centralize DefaultIfNull dispatch in Parser_default.hpp, eliminating 11 copy-pasted Parser*.hpp edits, covering all 10 previously missed types (filesystem::path, wstring, pair, expected, Result, span, string_view, c_array, rfl::Array, rfl::Tuple), and fixing unchecked MapType{}/VecType{} construction in MapParser/VectorParser. - Fix P0 const_cast + std::destroy_at UB in NamedTupleParser.hpp: already-empty omitted nullable fields are never mutated, mutable nullable fields reset safely via reset()/move-assignment, and omitted const/non-move-assignable nullable fields with non-empty DMIs return a clean rfl::Error; add catch (...) across all noexcept handlers. - Keep minimal nullable-alternative skip in ParserVariant/ParserRflVariant, atomic static_asserts in ParserBox/Ref/SharedPtr/UniquePtr, tabular static_asserts in ArrowReader/ArrowWriter, and ParserBitset direct specialization check. - Update docs and add focused JSON tests (dropping redundant YAML test).
…documentation Attach struct-level and per-field descriptions and deprecation messages via rfl::Metadata<T> specializations without embedding StringLiteral NTTPs in field types. - Rebased cleanly onto wave1/parser-symbol-isolation (b27a6f5) by threading _field_meta and _raw_name runtime parameters into build_named_tuple_field_schema with zero additional template parameters. - Preserves header diet (<type_traits> + <span>, zero <ranges>/<concepts>), null-pointer description guards, inline rfl::Deprecated<"msg", "", T> backwards compatibility, and Avro/Cap'n Proto schema support + tests. - Renamed tests/json_c_arrays_and_inheritance/test_c_array_schema_defaults.cpp to tests/json_c_arrays_and_inheritance/test_metadata.cpp.
- Split SchemaName.hpp (lightweight, zero Generic.hpp/Object.hpp includes) from SchemaExtension.hpp so make_type_name.hpp stays decoupled. - Avoid unnecessary std::string copy when SchemaName<T>::value() returns std::string by value. - Fix std::isalnum(static_cast<unsigned char>(ch)) UB in make_type_name.hpp. - Support SchemaExtension title, examples, x-* extensions, and inline_schema across JSON, Avro, and Cap'n Proto schema emitters.
…c storage (#70) Rebased onto wave1/stack-tip (428fa25), preserving Wave 1D symbol isolation (handle_missing_named_tuple_field, FieldNameLookup, write_named_tuple_field) and Wave 1A header trims. Polish from audit #16: - Omit ErrorKind::duplicate_field (0 emission sites in 4A; open enum allows adding it alongside duplicate-key readers / rfl::Alias in Wave 5). - Retain HasFromReflectionMethod Result<T> support so rfl::Timestamp reports ErrorKind::invalid_value via from_reflection without throwing or adding a one-off is_timestamp_v branch in Parser_default.hpp. - Harden touched noexcept boundaries (NamedTupleParser, TupleReader, MapReader, Validator, Timestamp, ParserTimePoint, Parser_default) with const std::exception& and catch (...). - Qualify cpp20::apply_to_fields / cpp26::apply_to_fields in bind_to_tuple.hpp to avoid ADL ambiguity when reflecting structs in rfl::internal (such as rfl::ErrorDetail). - Hoist CustomConvertible out of function scope in test_error_kind.cpp to fix GCC 13 -Werror=unused-local-typedefs.
…#120) Stacked cleanly on wave4/error-kind (4A) and Wave 1A (#135). Polish from audit #16: - Preserve Wave 1A <sstream> elimination across PatternValidator.hpp, comparisons.hpp, AnyOf.hpp, OneOf.hpp, and internal/cpp20/Result.hpp. - Move builtin_error_code_str, parse_builtin_error_code, compose_size_code, and compose_code_points_code out-of-line into src/rfl/internal/Error.cpp (wired into src/reflectcpp.cpp with RFL_API declarations in Error.hpp) to trim Error.hpp compile-time weight. - Fix P0 missing catch (...) in MapReader.hpp (both validator and non-validator key paths) and harden Validator.hpp and AllOf.hpp noexcept boundaries with const std::exception& and catch (...). - Guard constant nullptr V::code in validator_code.hpp with if constexpr to avoid GCC 13 -Werror=nonnull. - Add ASan+UBSan unit test coverage for non-std::exception throws in Validator, AllOf, and MapReader.
- Add rfl::AddNullFields and internal::add_null_fields_v to emit explicit nulls for empty optional/nullable fields without making them mandatory on read. - Integrate cleanly into Wave 1D's write_named_tuple_field helper while respecting Skip / SkipSerialization wrappers and _ignore_empty_containers.
Also wires cross-wave interop with DefaultIfNull (is_nullable), AddNullFields (skip force-emitting null for omitted TriState), and SchemaExtension (preserve annotations when flattening optional anyOf).
…okup Also wires cross-wave interop with AddNullFields, TriState (peel is_alias_v before is_skip_v in contains_skip_serialization_wrapper and contains_tri_state_wrapper), and DefaultIfNull (is_nullable).
…lohmann.hpp>) - Rebase #69 cleanly onto origin/main (290bdb2). - Deduplicate reserve_array, reserve_object, and emplace_field into rfl::nlohmann::internal in Writer.hpp and use insert_or_assign in Writer::emplace_in_object (eliminating default-null + overwrite). - Fix Reader integer range checks to use width-agnostic IntT/UIntT common-type bounds checks instead of hardcoded int64_t/uint64_t casts, and add a 32-bit custom basic_json bounds test. - Drop unnecessary (void) casts in Parser.hpp and document the msgpack-c v6 ABI layout constant (0x02). - Keep REFLECTCPP_NLOHMANN opt-in (OFF by default) with zero optional dependency leaks in CMake, reflectcpp-config.cmake.in, vcpkg, or Conan.
…I int64/uint64 schema format
Serializes and deserializes 64-bit (and wider) integers as base-10 strings
while preserving native numbers for narrower integers, letting one plain C++
struct work across binary/columnar formats and JS/TS/Protobuf-JSON APIs.
Emits {"type":"string","format":"int64"|"uint64"} in JSON Schema.
…pth DoS protection Bounds reflect-cpp's recursive parser walk on untrusted nested inputs (e.g. rfl::Generic or recursive rfl::Box<Node>) with zero overhead when unused and ErrorKind::syntax_error reporting. Clarifies that recursive third-party parsers (yaml-cpp, pugixml, toml++) are not guarded prior to reflect-cpp's walk.
Remove the dev-only vcpkg git submodule (.gitmodules and vcpkg gitlink) so FetchContent, CPM, and recursive git submodule consumers do not fetch the large vcpkg repository by default: - Add vcpkg-configuration.json (un-ignored in .gitignore, along with ignoring local /vcpkg/ clones) pinning default-registry (kind: git, repository: https://github.com/microsoft/vcpkg) to baseline 93ad765c7b66ab9ce97469ec23a90b15c3a14ee5. Using a git default-registry baseline works cleanly in Visual Studio Developer Prompt's bundled VC\vcpkg, in shallow or older local VCPKG_ROOT clones, and in GitHub Actions setup-vcpkg. - Read the pinned baseline single-source from vcpkg-configuration.json in .github/actions/setup-vcpkg/action.yml and check out vcpkg outside the source tree into ${RUNNER_TEMP}/vcpkg (`vcpkgDirectory`). - Drop submodules: recursive from .github/workflows/{linux,macos,windows,docs}.yaml. - Emit a clear FATAL_ERROR in CMakeLists.txt when top-level REFLECTCPP_USE_VCPKG=ON cannot find vcpkg via CMAKE_TOOLCHAIN_FILE, VCPKG_ROOT, $ENV{VCPKG_ROOT}, or a local vcpkg/ checkout. - Update vcpkg setup snippets in README.md, tests/README.md, docs/content/contributing.md, and docs/content/install.md, and drop GIT_SUBMODULES "" from the FetchContent quickstart snippets now that no submodules remain. Addresses #139.
clockblocker
force-pushed
the
upstream-queue
branch
from
December 2, 2026 13:26
0bca6f0 to
3d33e72
Compare
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.
Overview
discuss/ssotstacks speculative and design-heavy proposals directly on top ofupstream-queueso they stay continuously rebased and tested together while awaiting upstream maintainer design sign-off.Unlike
upstream-queue(which holds standalone, low-risk PRs ready to drip-feed upstream), every item here involves a public API shape, wire-format policy, core header footprint, or repository/CI workflow decision that benefits from upstream maintainer alignment first. Standalone bugfixes uncovered during development have already been extracted down intoupstream-queue.Dependency Structure
Most proposals target
upstream-queuedirectly and can be discussed, reshaped, or promoted in any order; only three stack on a single prerequisite:flowchart LR UQ["upstream-queue"] UQ --> P192["#192 DefaultTag"] UQ --> P193["#193 Int64AsString"] UQ --> P194["#194 NoDuplicateKeys"] UQ --> P195["#195 AddNullFields"] UQ --> P197["#197 nlohmann::json"] UQ --> P198["#198 MaxDepth"] UQ --> P199["#199 Remove vcpkg submodule"] UQ --> P200["#200 Metadata"] UQ --> P201["#201 Alias"] UQ --> P202["#202 SchemaName / SchemaExtension"] UQ --> P203["#203 Nullable / TriState"] UQ --> P196["#196 ErrorKind"] --> P205["#205 Error::code()"] UQ --> P204["#204 is_safe_default_constructible"] P204 --> P206["#206 DefaultIfMissing schema (#396)"] P204 --> P207["#207 DefaultIfNull (#796)"]Isolated Discussion PRs
Wire-Format & Validation Processors
rfl::DefaultTag<Discriminator, Tag>: Defaults a missingTaggedUniondiscriminator on read without mutating DOM trees or using an untaggedstd::variantfallback that swallows invalid tags. Open question: opt-in processor vs. union-type scoping vs.std::variantconvention.rfl::Int64AsString: Encodes 64-bit integers as base-10 strings to avoid IEEE 754 precision loss aboverfl::NoDuplicateKeys: Rejects repeated JSON and YAML keys with structured paths instead of silently taking last-write-wins, replacing external pre-parse walkers. Open question: reader/object-reader hook design and how unsupported formats (such astoml++or binary readers) should behave.rfl::AddNullFields: Emits explicitnullfor empty optionals and pointers on write without forcing fields to become required on read likerfl::NoOptionals. Open question: dedicated write processor vs. per-fieldrfl::Nullable<T>wrapper vs. write-onlyNoOptionals.<rfl/nlohmann.hpp>: Reads and writesnlohmann::jsonvalues directly without a string serialize-and-reparse round-trip. Open question: appetite for maintaining a second JSON backend across CMake, vcpkg, Conan, and CI.rfl::MaxDepth<N>: Caps nesting depth for untrusted inputs intorfl::Genericor recursive structs to prevent stack overflows. Open question:thread_localdepth guard vs. explicit reader state, and surfacing third-party parser limits.Error Taxonomy
rfl::ErrorKind: Classifies I/O, syntax, field, type, value, and validator failures structurally so callers stop scraping EnglishError::what()text. Open question: 9-value open enum baseline,ErrorDetail::operator==compatibility, and per-format rollout scope.Error::code()&ErrorDetail::code(stacked on #196): Attaches stable machine-readable validator codes (such as"minimum","pattern", and custom codes) to structured errors. Open question: canonical built-in code names, implicit validator opt-in, and equality semantics.Schema, Metadata & Field Wrappers
rfl::Metadata<T>: Attaches field descriptions and deprecation metadata out of band instead of baking doc strings into field types viarfl::Description. Open question: external metadata trait vs. keeping inline field wrappers.rfl::Alias: Accepts legacy wire key names on read without duplicate struct fields or custom reflectors. Open question: field wrapper vs. processor/trait, and interaction with case-transform processors.rfl::SchemaName<T>&rfl::SchemaExtension<T>: Customizes JSON Schema$defsnames, titles, examples, andx-*extensions directly in C++ instead of post-processing output JSON. Open question: trait design vs. inline wrappers, and adding an annotated node to the schema IR.rfl::Nullable<T>&rfl::TriState<T>: Distinguishes omitted keys from explicit nulls for HTTP PATCH and JSON-RPC APIs wherestd::optional<T>is ambiguous. Open question: shipping both vocabulary types vs. TriState alone, and overlap withrfl::AddNullFields.Defaults, Safety & Repo Hygiene
is_safe_default_constructible: Prevents hard compile errors from false-positivestd::is_default_constructible_vchecks on recursive aggregates and unconstrained wrappers. Open question: whether constraining 10 public wrapper constructors is worthwhile unless upstream #396 or upstream #796 lands.DefaultIfMissingJSON Schema defaults (stacked on #204; upstream #396): Emits C++ in-class member defaults into JSON Schema underrfl::DefaultIfMissingwithout duplicating them viarfl::DefaultVal. Open question: changing schema output for existingDefaultIfMissingcallers vs. a separate opt-in processor.rfl::DefaultIfNull(stacked on #204; upstream #796): Falls back to C++ in-class defaults when external APIs sendnullfor non-optional fields, avoiding pervasivestd::optionalwrapping. Open question: upstream demand, sibling-field default behavior, and nullability rules across wrappers.vcpkggit submodule: Stops default recursive clones (FetchContent, CPM) from downloading the entire vcpkg repository when building with bundled dependencies. Open question: removing the gitlink repo-wide (moving CI to a runner-temp checkout) vs. keeping it and documentingGIT_SUBMODULES "".