mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-03 08:46:19 +08:00
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:
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user