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

ircd::json: Add template to get tuple key string with runtime index.

This commit is contained in:
Jason Volk 2018-05-19 16:57:53 -07:00
parent 9e793fde82
commit 39e403c1d2

View file

@ -126,6 +126,24 @@ key()
return tuple_element<tuple, i>::key;
}
template<class tuple,
size_t i>
constexpr typename std::enable_if<i == tuple::size(), const char *>::type
key(const size_t &j)
{
return nullptr;
}
template<class tuple,
size_t i = 0>
constexpr typename std::enable_if<i < tuple::size(), const char *>::type
key(const size_t &j)
{
return j == i?
tuple_element<tuple, i>::key:
key<tuple, i + 1>(j);
}
template<size_t i,
class tuple>
enable_if_tuple<tuple, const char *const &>