mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 13:40:21 +00:00
unify stod/stoi invalid_argument::what parse
This is a hack to check whether given invalid_argument message belongs to stoi/stod. It is usually used to catch non-numeric user input where a number was expected.
This commit is contained in:
@@ -329,3 +329,16 @@ bool is_arm_mac() {
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @param what value returned by std::logic_error::what()
|
||||
* @returns if given std::invalid_argument message belongs to a stoi/stof
|
||||
* converison
|
||||
*/
|
||||
|
||||
bool invalid_arg_is_numeric(const char *what) {
|
||||
if (what == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return strcmp(what, "stoi") == 0 || strcmp(what, "stod") == 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user