feat: enhance timer
This commit is contained in:
parent
43c87e5904
commit
54d48e7d91
5 changed files with 133 additions and 8 deletions
|
|
@ -183,3 +183,24 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct as_optional {
|
||||
using type = optional<T>;
|
||||
};
|
||||
template<typename T>
|
||||
struct as_optional<optional<T>> {
|
||||
using type = optional<T>;
|
||||
};
|
||||
template<typename T>
|
||||
using as_optional_t = typename as_optional<T>::type;
|
||||
|
||||
template<typename Func>
|
||||
auto lift(Func func) {
|
||||
return [func](const auto&... optionals) -> as_optional_t<decltype(func(optionals.value()...))> {
|
||||
if ((optionals.has_value() && ...)) {
|
||||
return func(optionals.value()...);
|
||||
}
|
||||
return nullopt;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue