From b534939016328a12efa05f07044b11d34874cad6 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 6 Mar 2019 13:06:18 -0800 Subject: [PATCH] ircd::json::tuple: Improve property semantics. --- include/ircd/json/tuple/property.h | 34 ++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/include/ircd/json/tuple/property.h b/include/ircd/json/tuple/property.h index 776fdb271..3bb2bccd2 100644 --- a/include/ircd/json/tuple/property.h +++ b/include/ircd/json/tuple/property.h @@ -13,7 +13,9 @@ namespace ircd::json { - template struct property; + template + struct property; } /// The property template specifies a key/value member of a json::tuple @@ -33,19 +35,33 @@ struct ircd::json::property T value; - operator const T &() const; - operator T &(); - - property(T&& value) - :value{value} - {} + constexpr operator const T &() const; + constexpr operator T &(); property() = default; + constexpr property(T&& value); + constexpr property &operator=(T&& value); }; template -ircd::json::property::operator +constexpr +ircd::json::property::property(T&& value) +:value{std::forward(value)} +{} + +template +constexpr ircd::json::property & +ircd::json::property::operator=(T&& value) +{ + this->value = std::forward(value); + return *this; +} + +template +constexpr ircd::json::property::operator T &() { return value; @@ -53,7 +69,7 @@ T &() template -ircd::json::property::operator +constexpr ircd::json::property::operator const T &() const {