Repository navigation
Let a list as the last positional field take the remaining arguments in rfl::cli - #36
Closed
clockblocker wants to merge 1 commit into
Closed
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
clockblocker
force-pushed
the
wave-base-8
branch
from
November 15, 2026 08:21
c662644 to
e97a969
Compare
clockblocker
force-pushed
the
cli-list-positional
branch
3 times, most recently
from
November 17, 2026 04:36
ebe2135 to
d77d479
Compare
clockblocker
force-pushed
the
wave-base-8
branch
from
November 17, 2026 04:36
081ae39 to
c117e48
Compare
clockblocker
force-pushed
the
cli-list-positional
branch
from
November 17, 2026 05:11
d77d479 to
9956818
Compare
clockblocker
force-pushed
the
wave-base-8
branch
from
November 17, 2026 07:15
1cd8321 to
956becd
Compare
clockblocker
force-pushed
the
cli-list-positional
branch
from
November 17, 2026 07:15
9956818 to
166cf83
Compare
clockblocker
force-pushed
the
wave-base-8
branch
from
November 17, 2026 09:35
956becd to
6b14d2b
Compare
clockblocker
force-pushed
the
cli-list-positional
branch
from
November 17, 2026 09:35
166cf83 to
4e8812a
Compare
clockblocker
force-pushed
the
wave-base-8
branch
from
November 17, 2026 09:44
6b14d2b to
7a87ae7
Compare
clockblocker
force-pushed
the
cli-list-positional
branch
from
November 17, 2026 09:45
4e8812a to
03f4447
Compare
This was referenced Nov 21, 2026
…in rfl::cli If the last positional field is a list, it takes every positional argument after those of the other positional fields, each split at the commas: `app run a b,c` gives files = [a, b, c]. A list before other positional fields still takes one argument, and so does every positional field in the public resolve_args<T>, whose flat-map result cannot hold them. usage shows a list as the last positional as `<files>...`. Only inputs that used to fail change meaning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clockblocker
force-pushed
the
cli-list-positional
branch
from
November 25, 2026 12:08
03f4447 to
e2daa0b
Compare
clockblocker
force-pushed
the
wave-base-8
branch
from
November 25, 2026 12:08
7a87ae7 to
d5d4a6d
Compare
Owner
Author
|
Branch is preserved on |
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.
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.
Summary
Lets a list declared as the last
rfl::Positionalfield consume all remaining positional arguments inrfl::cli::read, instead of failing withToo many positional arguments. Purely additive.Example
Key details
std::optional/rfl::DefaultValallow 0.--files=a --files=b) still works, but mixing--files=...with bare positionals returns a conflict error.resolve_args<T, Ps>keeps its one-per-field flat-map behavior.cli.md("A list as the last positional argument").AI-authored. Depends on: #26.