0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::json::tuple: Use inline linkage for key() suite related.

This commit is contained in:
Jason Volk 2020-08-05 18:16:16 -07:00
parent 9f09eb6581
commit 1604ecd038
2 changed files with 15 additions and 14 deletions

View file

@ -23,9 +23,18 @@ noexcept
return tuple_element<tuple, i>::key;
}
template<size_t i,
class tuple>
inline enable_if_tuple<tuple, const char *>
key(const tuple &t)
noexcept
{
return std::get<i>(t).key;
}
template<class tuple,
size_t i>
constexpr typename std::enable_if<i == tuple::size(), const char *>::type
inline typename std::enable_if<i == tuple::size(), const char *>::type
key(const size_t &j)
noexcept
{
@ -34,22 +43,14 @@ noexcept
template<class tuple,
size_t i = 0>
constexpr typename std::enable_if<i < tuple::size(), const char *>::type
inline typename std::enable_if<i < tuple::size(), const char *>::type
key(const size_t &j)
noexcept
{
return j == i?
tuple_element<tuple, i>::key:
key<tuple, i + 1>(j);
}
if(likely(j != i))
return key<tuple, i + 1>(j);
template<size_t i,
class tuple>
enable_if_tuple<tuple, const char *>
key(const tuple &t)
noexcept
{
return std::get<i>(t).key;
return tuple_element<tuple, i>::key;
}
} // namespace json

View file

@ -167,7 +167,7 @@ noexcept
}
template<class tuple>
constexpr bool
inline bool
key_exists(const string_view &key)
{
return indexof<tuple>(key) < size<tuple>();