mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd::json: Add preliminary tuple iteration with mask of keys.
This commit is contained in:
parent
55603a3718
commit
93c9935338
1 changed files with 36 additions and 0 deletions
|
@ -473,6 +473,42 @@ for_each(tuple &t,
|
|||
for_each<i + 1>(t, std::forward<function>(f));
|
||||
}
|
||||
|
||||
template<class tuple,
|
||||
class function>
|
||||
void
|
||||
for_each(const tuple &t,
|
||||
const vector_view<const string_view> &mask,
|
||||
function&& f)
|
||||
{
|
||||
std::for_each(std::begin(mask), std::end(mask), [&t, &f]
|
||||
(const auto &key)
|
||||
{
|
||||
at(t, key, [&f, &key]
|
||||
(auto&& val)
|
||||
{
|
||||
f(key, val);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
template<class tuple,
|
||||
class function>
|
||||
void
|
||||
for_each(tuple &t,
|
||||
const vector_view<const string_view> &mask,
|
||||
function&& f)
|
||||
{
|
||||
std::for_each(std::begin(mask), std::end(mask), [&t, &f]
|
||||
(const auto &key)
|
||||
{
|
||||
at(t, key, [&f, &key]
|
||||
(auto&& val)
|
||||
{
|
||||
f(key, val);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
template<class tuple,
|
||||
class function,
|
||||
ssize_t i>
|
||||
|
|
Loading…
Reference in a new issue