mirror of
https://github.com/NixOS/nix
synced 2025-06-29 02:11:15 +02:00
string2Int(): Return std::optional
This commit is contained in:
parent
29a445840a
commit
6548b89cc4
17 changed files with 82 additions and 69 deletions
|
@ -87,7 +87,9 @@ protected:
|
|||
template<class I>
|
||||
Handler(I * dest)
|
||||
: fun([=](std::vector<std::string> ss) {
|
||||
if (!string2Int(ss[0], *dest))
|
||||
if (auto n = string2Int<I>(ss[0]))
|
||||
*dest = *n;
|
||||
else
|
||||
throw UsageError("'%s' is not an integer", ss[0]);
|
||||
})
|
||||
, arity(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue