From 39e403c1d2431f4adb801a5c210ac274be707a5f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 19 May 2018 16:57:53 -0700 Subject: [PATCH] ircd::json: Add template to get tuple key string with runtime index. --- include/ircd/json/tuple/tuple.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/ircd/json/tuple/tuple.h b/include/ircd/json/tuple/tuple.h index 6e1ecd680..d2e55d40a 100644 --- a/include/ircd/json/tuple/tuple.h +++ b/include/ircd/json/tuple/tuple.h @@ -126,6 +126,24 @@ key() return tuple_element::key; } +template +constexpr typename std::enable_if::type +key(const size_t &j) +{ + return nullptr; +} + +template +constexpr typename std::enable_if::type +key(const size_t &j) +{ + return j == i? + tuple_element::key: + key(j); +} + template enable_if_tuple