From 34e1dc99a17db48fbedd104d5b1fab3be9144b25 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 17 Dec 2020 16:20:32 -0800 Subject: [PATCH] ircd::stats: Add value assignment passthru semantic to item. --- include/ircd/stats.h | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/include/ircd/stats.h b/include/ircd/stats.h index b14515457..c4ce9622e 100644 --- a/include/ircd/stats.h +++ b/include/ircd/stats.h @@ -117,6 +117,12 @@ struct ircd::stats::item item(uint64_t *const &, const json::members &); item() = default; + + item &operator=(const uint64_t &val) & + { + static_cast(*this) = val; + return *this; + } }; template<> @@ -145,6 +151,12 @@ struct ircd::stats::item item(uint32_t *const &, const json::members &); item() = default; + + item &operator=(const uint32_t &val) & + { + static_cast(*this) = val; + return *this; + } }; template<> @@ -173,10 +185,15 @@ struct ircd::stats::item item(uint16_t *const &, const json::members &); item() = default; + + item &operator=(const uint16_t &val) & + { + static_cast(*this) = val; + return *this; + } }; -template<> -struct ircd::stats::item +template<> struct ircd::stats::item :item { uint64_t val {0}; @@ -194,6 +211,12 @@ struct ircd::stats::item item(const json::members &); item() = default; + + item &operator=(const uint64_t &val) & + { + static_cast(*this) = val; + return *this; + } }; template<> @@ -215,6 +238,12 @@ struct ircd::stats::item item(const json::members &); item() = default; + + item &operator=(const uint32_t &val) & + { + static_cast(*this) = val; + return *this; + } }; template<> @@ -236,4 +265,10 @@ struct ircd::stats::item item(const json::members &); item() = default; + + item &operator=(const uint16_t &val) & + { + static_cast(*this) = val; + return *this; + } };