mirror of
https://github.com/matrix-construct/construct
synced 2025-03-13 21:10:32 +01:00
ircd::json::tuple: Add membership test for keys selection.
This commit is contained in:
parent
2b12c8a9c5
commit
0cb79728f9
1 changed files with 19 additions and 0 deletions
|
@ -30,6 +30,7 @@ struct ircd::json::keys
|
|||
struct exclude;
|
||||
|
||||
size_t count() const;
|
||||
bool has(const string_view &) const;
|
||||
|
||||
operator vector_view<const string_view>() const;
|
||||
|
||||
|
@ -171,6 +172,24 @@ const
|
|||
return { this->data(), this->count() };
|
||||
}
|
||||
|
||||
template<class tuple>
|
||||
bool
|
||||
ircd::json::keys<tuple>::has(const string_view &key)
|
||||
const
|
||||
{
|
||||
const auto &start
|
||||
{
|
||||
begin(*this)
|
||||
};
|
||||
|
||||
const auto &stop
|
||||
{
|
||||
start + this->count()
|
||||
};
|
||||
|
||||
return std::find(start, stop, key) != stop;
|
||||
}
|
||||
|
||||
template<class tuple>
|
||||
size_t
|
||||
ircd::json::keys<tuple>::count()
|
||||
|
|
Loading…
Add table
Reference in a new issue