mirror of
https://github.com/NixOS/nix
synced 2025-07-05 16:31:47 +02:00
string2Int(): Return std::optional
This commit is contained in:
parent
29a445840a
commit
6548b89cc4
17 changed files with 82 additions and 69 deletions
|
@ -70,10 +70,9 @@ template<class N> N getIntArg(const string & opt,
|
|||
s.resize(s.size() - 1);
|
||||
}
|
||||
}
|
||||
N n;
|
||||
if (!string2Int(s, n))
|
||||
throw UsageError("'%1%' requires an integer argument", opt);
|
||||
return n * multiplier;
|
||||
if (auto n = string2Int<N>(s))
|
||||
return *n * multiplier;
|
||||
throw UsageError("'%1%' requires an integer argument", opt);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue