From 1fa3d2c024978b6d7bc4b131708441bd2908294b Mon Sep 17 00:00:00 2001 From: Zhao <19891109@qq.com> Date: Thu, 14 Nov 2024 23:48:19 +0800 Subject: [PATCH] Add the Parameterless Constructor, Three-way comparison operator and Equality comparison operator. (#258) Co-authored-by: zhaoshunxian --- include/rfl/Flatten.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/rfl/Flatten.hpp b/include/rfl/Flatten.hpp index 62beb18b..04ea6f38 100644 --- a/include/rfl/Flatten.hpp +++ b/include/rfl/Flatten.hpp @@ -15,6 +15,8 @@ struct Flatten { /// The underlying type. using Type = std::remove_cvref_t; + Flatten() = default; + Flatten(const Type& _value) : value_(_value) {} Flatten(Type&& _value) noexcept : value_(std::forward(_value)) {} @@ -91,6 +93,18 @@ struct Flatten { return *this; } + /// Three-way comparison operator + template + auto operator<=>(const Flatten& _f) const { + return value_ <=> _f.value_; + } + + /// Equality comparison operator. + template + bool operator==(const Flatten& _f) const { + return value_ == _f.get(); + } + /// Assigns the underlying object. void set(const Type& _value) { value_ = _value; }