mirror of
https://github.com/matrix-construct/construct
synced 2025-02-20 02:30:07 +01:00
ircd::json: Add a bang ADL for falsy semantic on object/array.
This commit is contained in:
parent
365fabe638
commit
01235e3851
2 changed files with 15 additions and 1 deletions
|
@ -27,6 +27,7 @@ namespace ircd::json
|
|||
struct array;
|
||||
|
||||
bool empty(const array &);
|
||||
bool operator!(const array &);
|
||||
|
||||
string_view stringify(mutable_buffer &buf, const string_view *const &begin, const string_view *const &end);
|
||||
string_view stringify(mutable_buffer &buf, const std::string *const &begin, const std::string *const &end);
|
||||
|
@ -169,7 +170,13 @@ const
|
|||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::empty(const json::array &array)
|
||||
ircd::json::operator!(const array &array)
|
||||
{
|
||||
return empty(array);
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::empty(const array &array)
|
||||
{
|
||||
return array.empty();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace ircd::json
|
|||
struct object;
|
||||
|
||||
bool empty(const object &);
|
||||
bool operator!(const object &);
|
||||
template<name_hash_t key, class T = string_view> T at(const object &);
|
||||
template<name_hash_t key, class T = string_view> T get(const object &, const T &def = {});
|
||||
}
|
||||
|
@ -348,6 +349,12 @@ const
|
|||
return std::distance(begin(), end());
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::operator!(const object &object)
|
||||
{
|
||||
return empty(object);
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::empty(const object &object)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue