Add the Parameterless Constructor, Three-way comparison operator and Equality comparison operator. (#258)

Co-authored-by: zhaoshunxian <zhaoshunxian@cviauto.com>
This commit is contained in:
Zhao
2024-11-14 16:48:19 +01:00
committed by GitHub
co-authored by zhaoshunxian
parent 505cbf1e07
commit 1fa3d2c024
+14
View File
@@ -15,6 +15,8 @@ struct Flatten {
/// The underlying type.
using Type = std::remove_cvref_t<T>;
Flatten() = default;
Flatten(const Type& _value) : value_(_value) {}
Flatten(Type&& _value) noexcept : value_(std::forward<Type>(_value)) {}
@@ -91,6 +93,18 @@ struct Flatten {
return *this;
}
/// Three-way comparison operator
template <class U>
auto operator<=>(const Flatten<U>& _f) const {
return value_ <=> _f.value_;
}
/// Equality comparison operator.
template <class U>
bool operator==(const Flatten<U>& _f) const {
return value_ == _f.get();
}
/// Assigns the underlying object.
void set(const Type& _value) { value_ = _value; }