0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-19 00:10:59 +01:00

ircd::json::tuple: Improve property semantics.

This commit is contained in:
Jason Volk 2019-03-06 13:06:18 -08:00
parent 9f4890a517
commit b534939016

View file

@ -13,7 +13,9 @@
namespace ircd::json
{
template<const char *const &name, class value_type> struct property;
template<const char *const &name,
class value_type>
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<const char *const &name,
class T>
ircd::json::property<name, T>::operator
constexpr
ircd::json::property<name, T>::property(T&& value)
:value{std::forward<T>(value)}
{}
template<const char *const &name,
class T>
constexpr ircd::json::property<name, T> &
ircd::json::property<name, T>::operator=(T&& value)
{
this->value = std::forward<T>(value);
return *this;
}
template<const char *const &name,
class T>
constexpr ircd::json::property<name, T>::operator
T &()
{
return value;
@ -53,7 +69,7 @@ T &()
template<const char *const &name,
class T>
ircd::json::property<name, T>::operator
constexpr ircd::json::property<name, T>::operator
const T &()
const
{