「view this page in B3 βῆτα server」

Revisions №61414

branch: master 「№61414」
Commited by: Vikram K. Mulligan
GitHub commit link: 「e3f2a694e904afc8」 「№4941」
Difference from previous tested commit:  code diff
Commit date: 2020-09-03 21:32:28

Merge pull request #4941 from RosettaCommons/vmullig/tag_getOption_for_bool_strings Try to address cases in which a developer has provided a default value for a boolean as a string in parse_my_tag(). This code compiles correctly, but doesn't do what one expects: ```c++ bool myoption = tag->getOption<bool>( "myoption", "false" ); ``` The developer _expects_ that if the user doesn't specify the option "myoption", it will default to `false`. Unfortunately, the string literal `"false"` is sent to the `Tag::getOption<bool>( std::string const &, bool const )` function as a `char*`, which can be cast automatically to a bool. Any non-`nullptr` value gets interpreted as `true`, however, so the default is set to `true`. The general solution (since even if we fix all the instances currently in the codebase, this will creep back in) is to implement `Tag::getOption<bool>( std::string const &, char const * )`, which parses and interprets the default string and converts it to a `bool`. This PR does this. Thank you to @danielzaidman for bringing this issue to light!

...