Fix string comparison in C++

This commit is contained in:
Olivier Goffart 2020-11-03 19:42:01 +01:00
parent c3ba10fa90
commit 4910c1fdaa

View file

@ -107,6 +107,15 @@ struct SharedString
return std::string_view(a) != std::string_view(b); return std::string_view(a) != std::string_view(b);
} }
friend bool operator<(const SharedString &a, const SharedString &b)
{ return std::string_view(a) < std::string_view(b); }
friend bool operator<=(const SharedString &a, const SharedString &b)
{ return std::string_view(a) <= std::string_view(b); }
friend bool operator>(const SharedString &a, const SharedString &b)
{ return std::string_view(a) > std::string_view(b); }
friend bool operator>=(const SharedString &a, const SharedString &b)
{ return std::string_view(a) >= std::string_view(b); }
/// Writes the \a shared_string to the specified \a stream and returns a reference to the /// Writes the \a shared_string to the specified \a stream and returns a reference to the
/// stream. /// stream.
friend std::ostream &operator<<(std::ostream &stream, const SharedString &shared_string) friend std::ostream &operator<<(std::ostream &stream, const SharedString &shared_string)