cmdopt2/args: add vector bind
This commit is contained in:
parent
86eafa366d
commit
153844eded
@ -66,6 +66,26 @@ namespace cruft::cmdopt2 {
|
||||
return get ();
|
||||
}
|
||||
|
||||
template <typename ValueT>
|
||||
BaseT
|
||||
bind (std::vector<ValueT> &ref)
|
||||
{
|
||||
if (!repeat_)
|
||||
throw std::logic_error ("vector argument with non-repeatable argument");
|
||||
|
||||
if constexpr (parseable<ValueT>) {
|
||||
acceptor1 = [&ref] (char const* str) {
|
||||
ref.emplace_back (parse::from_string<ValueT> (str));
|
||||
};
|
||||
} else {
|
||||
acceptor1 = [&ref] (char const* str) {
|
||||
ref.emplace_back (str);
|
||||
};
|
||||
}
|
||||
|
||||
return get ();
|
||||
}
|
||||
|
||||
BaseT
|
||||
get (void) const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user