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:
parent
9e793fde82
commit
39e403c1d2
1 changed files with 18 additions and 0 deletions
|
@ -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 &>
|
||||
|
|
Loading…
Reference in a new issue