It is a singleton, so there are issues when creating multiple CmdLine objects within the same app.
It is used in the constructor of the positional args rather then on adding thm to a CmdLine. It means the order in which the args objecs were created matters. But what really should matter is the order in which they are specified to be parsed.
See also https://sourceforge.net/p/tclap/bugs/25/ for related issues with static variables. Fixing this in a backwards compatible way may be a bit tricky (because the Arg doesn't necessarily have access to the CmdLine object when it is created), and given that it's a pretty rare use-case (multiple CmdLine objects + Unlabeled arguments) I'm not convinced it's worth it. It should be fixed for 2.0 though. However, non-breaking patches would be welcomed.
Last edit: Daniel Aarno 2021-08-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
See also https://sourceforge.net/p/tclap/bugs/25/ for related issues with static variables. Fixing this in a backwards compatible way may be a bit tricky (because the Arg doesn't necessarily have access to the CmdLine object when it is created), and given that it's a pretty rare use-case (multiple CmdLine objects + Unlabeled arguments) I'm not convinced it's worth it. It should be fixed for 2.0 though. However, non-breaking patches would be welcomed.
Last edit: Daniel Aarno 2021-08-16
I think this may work in 1.4:
In CmdLine.h, add a member variable (
bool _optionalUnlabeled;), initialized to false in the constructor, then check in this method:and remove the check in the unlabeled objects.