1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:57:44 +00:00

AK: Add String::is_one_of for variadic string comparison

This commit is contained in:
Timothy Flynn 2023-01-14 09:59:18 -05:00 committed by Linus Groh
parent 9db9b2f9be
commit bd9b65e82f
2 changed files with 22 additions and 0 deletions

View file

@ -86,6 +86,12 @@ public:
// NOTE: UTF-8 is defined in a way that lexicographic ordering of code points is equivalent to lexicographic ordering of bytes.
[[nodiscard]] int operator<=>(String const& other) const { return this->bytes_as_string_view().compare(other.bytes_as_string_view()); }
template<typename... Ts>
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts&&... strings) const
{
return (this->operator==(forward<Ts>(strings)) || ...);
}
[[nodiscard]] u32 hash() const;
template<Arithmetic T>