Ask Your Question

Revision history [back]

CommandLineParser: How to catch invalid input to numeric parameter

Is there a way to know if a user passes invalid input to a numeric argument with CommandLineParser? e.g. if this is my command line:

./app -s=sss

then this code:

markerSize = parser.get<float>("s");

returns 0 and an error message is printed to the console. I need to know the difference between 0 and invalid input. It doesn't throw an exception so I can't use try … catch.