mirror of
https://github.com/sogou/workflow.git
synced 2026-10-17 04:31:07 +08:00
improve args.h.
This commit is contained in:
@@ -46,6 +46,33 @@ namespace details
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
inline bool extract_impl(size_t todo, int& index, bool& r, char**& p, Arg& arg){
|
||||
if(!r||index>=todo){
|
||||
return false;
|
||||
}
|
||||
|
||||
r = extract(*p, arg);
|
||||
|
||||
if(!r){
|
||||
return false;
|
||||
}
|
||||
|
||||
index++;
|
||||
p++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename ... ARGS>
|
||||
inline int parse(size_t todo, char ** p, ARGS & ... args)
|
||||
{
|
||||
int index = 0;
|
||||
bool r = true;
|
||||
(void)std::initializer_list<int>{(extract_impl(todo, index, r, p, args), 0)...};
|
||||
return index;
|
||||
}
|
||||
|
||||
template <typename ... ARGS>
|
||||
inline int parse(int todo, char ** p, ARGS & ... args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user