Closed Zeldax64 closed 10 months ago
Thanks for the report.
Per the discussion in #260 and #226, copy and move constructors for argparse::ArgumentParser
have now been deleted. You will not be able to do this (i.e., use a maker function and assign into a variable) starting from the next release.
Sorry about the inconvenience but the parser class (with its string_views, references, iterators etc.) is not written in a way that is copy-friendly. Copying the parser invalidates references and only works OK under specific cases. It is instead meant to be setup and run from a single function.
The argparse presents an odd behavior on operator= and --help. Consider the following code:
The program requires a positional argument. When launching it with invalid argument
./main
, an exception is raised and caught, so the program finishes printing the --help message. However, when launching the program as./main --help
the program only prints "Usage:". I believe the problem occurs in the assignment operator. I'm sending the code for easy reproducibility with cmake.argparse-issue.zip