BLI: add comparison operators for StringRef

The semantic of those is the same as for std::string_view.
This commit is contained in:
Jacques Lucke 2020-09-07 16:09:48 +02:00
parent 0774fdbeb6
commit d71458d919
1 changed files with 20 additions and 0 deletions

View File

@ -404,6 +404,26 @@ inline bool operator!=(StringRef a, StringRef b)
return !(a == b);
}
inline bool operator<(StringRef a, StringRef b)
{
return std::string_view(a) < std::string_view(b);
}
inline bool operator>(StringRef a, StringRef b)
{
return std::string_view(a) > std::string_view(b);
}
inline bool operator<=(StringRef a, StringRef b)
{
return std::string_view(a) <= std::string_view(b);
}
inline bool operator>=(StringRef a, StringRef b)
{
return std::string_view(a) >= std::string_view(b);
}
/**
* Return true when the string starts with the given prefix.
*/