Repository navigation
Accept const argv and ranges of arguments in rfl::cli::read - #784
Merged
liuzicheng1987 merged 1 commit intoNov 18, 2026
Merged
liuzicheng1987 merged 1 commit into
liuzicheng1987 merged 1 commit into
Conversation
clockblocker
force-pushed
the
cli-const-argv-and-ranges-main
branch
from
November 16, 2026 04:55
f111f1a to
a6dc52d
Compare
Collaborator
|
@clockblocker there appear to be merge conflicts because of your other PR. Could you fix them? |
clockblocker
force-pushed
the
cli-const-argv-and-ranges-main
branch
from
November 17, 2026 03:49
a6dc52d to
287c961
Compare
Implements munich-data-engineering#623. read and parse_argv take `const char* const argv[]` and `const wchar_t* const argv[]`; the `char*[]`/`wchar_t*[]` overloads stay and forward to them, so `&rfl::cli::read<T>` still converts to (int, char**). New overloads take a range of narrow or wide strings or a braced list. They parse every element, including the first, and reject null pointers with an error. A range of narrow strings must be a forward range of lvalue strings, pointers or string_views, because the parser keeps a string_view to each element. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clockblocker
force-pushed
the
cli-const-argv-and-ranges-main
branch
from
November 17, 2026 17:38
287c961 to
158a0cc
Compare
Collaborator
|
@clockblocker thanks, I am merging. |
liuzicheng1987
merged commit Nov 18, 2026
a2f0e74
into
munich-data-engineering:main
176 checks passed
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.
AI-authored
Why
Boost.Program_options, CLI11 and cxxopts take
const char* const*argv, and Boost.Program_options and CLI11 also take astd::vector<std::string>.#623 asks for both in rfl::cli.
Today a
const char**argv needs aconst_cast, and arguments from a container or a test need a fake argv.Implements the three points of #623.
readandparse_argvtakeconst char* const argv[]andconst wchar_t* const argv[], soconst char**callers compile. The(int, char* argv[])and(int, wchar_t* argv[])overloads stay and forward to them.read<T>(args)andparse_argv(args)accept a range of narrow strings (std::vector<std::string>,std::span<char*>,const char* const[], ...), a braced list (read<T>({"--port=8080"})), or a range of wide strings (converted to UTF-8). A null pointer in a range or array of pointers is an error; in a braced list it is undefined behaviour at the call site, and the docs say so.std::string_viewto each element, so the range must be astd::forward_rangeof lvalue strings, pointers orstring_views.std::views::istream<std::string>and views yielding temporarystd::strings don't compile. Wide ranges may be single-pass.argv[0]and keep their error messages; the wide ones no longer convertargv[0]. The docs show thestd::span(argv, argc)pitfall.parse_argv(argc, argv), the new publicparse_argv(args)reads-5as a short option, since it doesn't know the struct;readreads it as a negative number.The four
char*[]/wchar_t*[]forwarding overloads stay: without them&rfl::cli::read<T>no longer converts to(int, char**). The README shows thestd::vector<std::string>overload.Tests:
tests/cli/test_const_argv_and_ranges.cpp(18 tests plusstatic_asserts for the rejected ranges). json, cli and generic pass (Apple clang); everytests/cli/*.cppcompiles with g++-16-O3 -Wall -Werror. The docs example was compiled and run.🤖 Generated with Claude Code