Repository navigation
Allow rvalue references to be use with add_flag with no assignment - #1173
Conversation
Allow rvalue references to be used with `add_flag` without assignment.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1173 +/- ##
===========================================
Coverage 100.00% 100.00%
===========================================
Files 17 17
Lines 4546 5166 +620
Branches 0 1061 +1061
===========================================
+ Hits 4546 5166 +620 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This is basically saying that if you pass a non const string here, that is an assignment variable, so the results of parsing that flag would get passed into that variable. |
|
I like it, may add a few more tests later on, but this looks good, I am going to merge it |
I see, but in this case the |
|
Yeah you are probably right, that comment is probably copied from the other overloads. I will clean that up in another PR soon. |
I am starting to use CLI11 in a project and I came across an inconvenience in code like this
As far as I can tell. I cannot directly use the description here. The reason seems to be to distinguish between assignment and description. So only
const std::stringorconst char*and so on can be used here. But aconst std::string &&can not be used.With the changes in the PR the code can also be written like this:
The
add_flagfunction can then be used with a const string or an rvalue reference to a string.A bit OT: I was a bit confused by this part of the existing comment
if a variable string is passed that variable will be assigned the results from the flagI think this might be wrong, but I am not sure.