mirror of
https://github.com/NixOS/nix
synced 2025-07-05 12:21:48 +02:00
string2Int(): Return std::optional
This commit is contained in:
parent
29a445840a
commit
6548b89cc4
17 changed files with 82 additions and 69 deletions
|
@ -230,7 +230,9 @@ template<typename T>
|
|||
void BaseSetting<T>::set(const std::string & str, bool append)
|
||||
{
|
||||
static_assert(std::is_integral<T>::value, "Integer required.");
|
||||
if (!string2Int(str, value))
|
||||
if (auto n = string2Int<T>(str))
|
||||
value = *n;
|
||||
else
|
||||
throw UsageError("setting '%s' has invalid value '%s'", name, str);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue