diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-01-08 12:22:21 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-01-08 12:22:21 +0100 |
commit | 6548b89cc4eb214cb4632fd4332c610f2d1f0a9d (patch) | |
tree | 1d9044a0f0602993c5a538ce2231d8d569aeb2a5 /src/libutil/args.hh | |
parent | 29a445840a4f01dfb1533806f8dfc28f7dc4bee9 (diff) |
string2Int(): Return std::optional
Diffstat (limited to 'src/libutil/args.hh')
-rw-r--r-- | src/libutil/args.hh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libutil/args.hh b/src/libutil/args.hh index 62b9516d8..823d843aa 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -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) |