0
0
Fork 0
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:
Jason Volk 2017-10-28 12:29:28 -07:00
parent 55603a3718
commit 93c9935338

View file

@ -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>