diff --git a/include/ircd/json/tuple/indexof.h b/include/ircd/json/tuple/indexof.h index 046026ed1..d13273dc3 100644 --- a/include/ircd/json/tuple/indexof.h +++ b/include/ircd/json/tuple/indexof.h @@ -41,7 +41,7 @@ noexcept template -inline enable_if_tuple +inline constexpr enable_if_tuple indexof(const char (&name)[N]) noexcept { @@ -54,7 +54,7 @@ noexcept template -inline enable_if_tuple +inline constexpr enable_if_tuple indexof(const string_view &name) noexcept { diff --git a/include/ircd/json/tuple/key.h b/include/ircd/json/tuple/key.h index 775bfa326..cd4e3affe 100644 --- a/include/ircd/json/tuple/key.h +++ b/include/ircd/json/tuple/key.h @@ -25,7 +25,7 @@ noexcept template -inline enable_if_tuple +inline constexpr enable_if_tuple key(const tuple &t) noexcept { @@ -34,7 +34,7 @@ noexcept template -inline typename std::enable_if::type +inline constexpr typename std::enable_if::type key(const size_t &j) noexcept { @@ -43,7 +43,7 @@ noexcept template -inline typename std::enable_if::type +inline constexpr typename std::enable_if::type key(const size_t &j) noexcept { diff --git a/include/ircd/json/tuple/keys.h b/include/ircd/json/tuple/keys.h index dd191b336..4be48351a 100644 --- a/include/ircd/json/tuple/keys.h +++ b/include/ircd/json/tuple/keys.h @@ -37,17 +37,17 @@ struct ircd::json::keys /// `include` or `exclude` classes which will set these bits appropriately. template struct ircd::json::keys::selection -:std::bitset +:util::bitset { template constexpr bool for_each(closure&&) const; template constexpr it transform(it, const it end) const; - bool has(const string_view &) const; - void set(const string_view &, const bool & = true); - void set(const size_t &, const bool & = true); + constexpr bool has(const string_view &) const; + constexpr void set(const string_view &, const bool = true); + constexpr void set(const size_t &, const bool = true); // Note the default all-bits set. - constexpr selection(const uint64_t &val = -1) - :std::bitset{val} + constexpr selection(const uint128_t val = -1) + :util::bitset{val} {} static_assert(T::size() <= sizeof(uint64_t) * 8); @@ -60,16 +60,22 @@ template struct ircd::json::keys::include :selection { - include(const vector_view &list) + constexpr include(const vector_view list) :selection{0} { - assert(this->none()); - for(const auto &key : list) - this->set(key, true); + for(const auto key : list) + selection::set(key, true); } - include(const std::initializer_list &list) - :include(vector_view(list)) + constexpr include(const std::initializer_list list) + :selection{0} + { + for(const auto key : list) + selection::set(key, true); + } + + constexpr include() + :selection{0} {} }; @@ -80,16 +86,22 @@ template struct ircd::json::keys::exclude :selection { - exclude(const vector_view &list) + constexpr exclude(const vector_view list) :selection{} { - assert(this->all()); - for(const auto &key : list) - this->set(key, false); + for(const auto key : list) + selection::set(key, false); } - exclude(const std::initializer_list &list) - :exclude(vector_view(list)) + constexpr exclude(const std::initializer_list list) + :selection{} + { + for(const auto key : list) + selection::set(key, false); + } + + constexpr exclude() + :selection{} {} }; @@ -98,27 +110,27 @@ struct ircd::json::keys::exclude // template -inline void +inline constexpr void ircd::json::keys::selection::set(const string_view &key, - const bool &val) + const bool val) { - this->set(json::indexof(key), val); + selection::set(json::indexof(key), val); } template -inline void +inline constexpr void ircd::json::keys::selection::set(const size_t &pos, - const bool &val) + const bool val) { - this->std::bitset::set(pos, val); + util::bitset::set(pos, val); } template -inline bool +inline constexpr bool ircd::json::keys::selection::has(const string_view &key) const { - return this->test(json::indexof(key)); + return util::bitset::test(json::indexof(key)); } template @@ -128,7 +140,7 @@ ircd::json::keys::selection::transform(it i, const it end) const { - this->for_each([&i, &end](auto&& key) + for_each([&i, &end](auto&& key) { if(i == end) return false; @@ -148,7 +160,7 @@ ircd::json::keys::selection::for_each(closure&& function) const { for(size_t i(0); i < T::size(); ++i) - if(this->test(i)) + if(util::bitset::test(i)) if(!function(key(i))) return false;