0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd::json: Use the defined() rather than default ctor / cleanup.

This commit is contained in:
Jason Volk 2017-12-12 13:23:20 -07:00
parent ff76d3e061
commit cea114d41d

View file

@ -64,11 +64,11 @@ struct tuple
using tuple_type = std::tuple<T...>; using tuple_type = std::tuple<T...>;
using super_type = tuple<T...>; using super_type = tuple<T...>;
static constexpr size_t size();
operator json::value() const; operator json::value() const;
operator crh::sha256::buf() const; operator crh::sha256::buf() const;
static constexpr size_t size();
template<class... U> tuple(const tuple<U...> &); template<class... U> tuple(const tuple<U...> &);
tuple(const json::object &); tuple(const json::object &);
tuple(const json::iov &); tuple(const json::iov &);
@ -411,7 +411,7 @@ get(const tuple &t,
using value_type = tuple_value_type<tuple, idx>; using value_type = tuple_value_type<tuple, idx>;
//TODO: undefined //TODO: undefined
return ret != value_type{}? ret : def; return defined(ret)? ret : def;
} }
template<size_t hash, template<size_t hash,
@ -436,7 +436,7 @@ get(tuple &t,
//TODO: undefined //TODO: undefined
auto &ret{get<hash, tuple>(t)}; auto &ret{get<hash, tuple>(t)};
using value_type = decltype(ret); using value_type = decltype(ret);
return ret != value_type{}? ret : def; return defined(ret)? ret : def;
} }
template<size_t hash, template<size_t hash,
@ -456,8 +456,8 @@ at(const tuple &t)
using value_type = tuple_value_type<tuple, idx>; using value_type = tuple_value_type<tuple, idx>;
//TODO: undefined //TODO: XXX
if(ret == value_type{}) if(!defined(ret))
throw not_found("%s", key<idx>(t)); throw not_found("%s", key<idx>(t));
return ret; return ret;
@ -480,8 +480,8 @@ at(tuple &t)
using value_type = tuple_value_type<tuple, idx>; using value_type = tuple_value_type<tuple, idx>;
//TODO: undefined //TODO: XXX
if(ret == value_type{}) if(!defined(ret))
throw not_found("%s", key<idx>(t)); throw not_found("%s", key<idx>(t));
return ret; return ret;
@ -505,7 +505,7 @@ at(const tuple &t)
using value_type = tuple_value_type<tuple, idx>; using value_type = tuple_value_type<tuple, idx>;
//TODO: undefined //TODO: undefined
if(ret == value_type{}) if(!defined(ret))
throw not_found("%s", name); throw not_found("%s", name);
return ret; return ret;
@ -529,7 +529,7 @@ at(tuple &t)
using value_type = tuple_value_type<tuple, idx>; using value_type = tuple_value_type<tuple, idx>;
//TODO: undefined //TODO: undefined
if(ret == value_type{}) if(!defined(ret))
throw not_found("%s", name); throw not_found("%s", name);
return ret; return ret;