0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-09 20:18:34 +02:00

ircd::json: Add a bang ADL for falsy semantic on object/array.

This commit is contained in:
Jason Volk 2018-01-30 10:14:41 -08:00
parent 365fabe638
commit 01235e3851
2 changed files with 15 additions and 1 deletions

View file

@ -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();
}

View file

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