0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::json: Add back support for tuple string reference indexing overloads.

This commit is contained in:
Jason Volk 2018-02-24 19:45:57 -08:00
parent 4643a78c47
commit 114bee0381

View file

@ -157,6 +157,24 @@ indexof()
return equal? i : indexof<tuple, hash, i + 1>();
}
template<class tuple,
const char *const &name,
size_t i>
constexpr typename std::enable_if<i == size<tuple>(), size_t>::type
indexof()
{
return size<tuple>();
}
template<class tuple,
const char *const &name,
size_t i = 0>
constexpr typename std::enable_if<i < size<tuple>(), size_t>::type
indexof()
{
return indexof<tuple, name_hash(name)>();
}
template<class tuple,
size_t i>
constexpr typename std::enable_if<i == size<tuple>(), size_t>::type
@ -412,6 +430,40 @@ get(tuple &t,
return defined(ret)? ret : def;
}
template<const char *const &name,
class tuple>
enable_if_tuple<tuple, const tuple_value_type<tuple, indexof<tuple, name>()> &>
get(const tuple &t)
{
return get<name_hash(name), tuple>(t);
}
template<const char *const &name,
class tuple>
enable_if_tuple<tuple, tuple_value_type<tuple, indexof<tuple, name>()>>
get(const tuple &t,
const tuple_value_type<tuple, indexof<tuple, name>()> &def)
{
return get<name_hash(name), tuple>(t, def);
}
template<const char *const &name,
class tuple>
enable_if_tuple<tuple, tuple_value_type<tuple, indexof<tuple, name>()>>
get(tuple &t)
{
return get<name_hash(name), tuple>(t);
}
template<const char *const &name,
class tuple>
enable_if_tuple<tuple, tuple_value_type<tuple, indexof<tuple, name>()>>
get(tuple &t,
tuple_value_type<tuple, indexof<tuple, hash>()> &def)
{
return get<name_hash(name), tuple>(t, def);
}
template<size_t hash,
class tuple>
enable_if_tuple<tuple, const tuple_value_type<tuple, indexof<tuple, hash>()> &>
@ -460,6 +512,22 @@ at(tuple &t)
return ret;
}
template<const char *const &name,
class tuple>
enable_if_tuple<tuple, const tuple_value_type<tuple, indexof<tuple, name>()> &>
at(const tuple &t)
{
return at<name_hash(name), tuple>(t);
}
template<const char *const &name,
class tuple>
enable_if_tuple<tuple, tuple_value_type<tuple, indexof<tuple, name>()> &>
at(tuple &t)
{
return at<name_hash(name), tuple>(t);
}
template<class tuple,
class function,
size_t i>