xo-object: spaceship operator for gp<T> + gp<String>

This commit is contained in:
Roland Conybeare 2025-12-06 14:16:34 -05:00
commit c6876ed31a
2 changed files with 31 additions and 0 deletions

View file

@ -69,6 +69,18 @@ namespace xo {
T * operator->() const { return ptr_; }
T & operator*() const { return *ptr_; }
auto operator<=>(gc_ptr<T> other) const
requires std::three_way_comparable<T>
{
return *ptr_ <=> *other.ptr_;
}
bool operator==(gc_ptr<T> other) const
requires std::equality_comparable<T>
{
return *ptr_ == *other.ptr_;
}
private:
T * ptr_ = nullptr;
};