diff --git a/AK/String.h b/AK/String.h index f7626d07e9..e4221f037f 100644 --- a/AK/String.h +++ b/AK/String.h @@ -302,6 +302,18 @@ public: return (... || this->operator==(forward(strings))); } + template + [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_case(Ts&&... strings) const + { + return (... || + [this, &strings]() -> bool { + if constexpr (requires(Ts a) { a.view()->StringView; }) + return this->equals_ignoring_case(forward(strings.view())); + else + return this->equals_ignoring_case(forward(strings)); + }()); + } + private: RefPtr m_impl; }; diff --git a/AK/StringView.h b/AK/StringView.h index 821b706b90..d37ee4d8c9 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -279,6 +279,18 @@ public: return (... || this->operator==(forward(strings))); } + template + [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_case(Ts&&... strings) const + { + return (... || + [this, &strings]() -> bool { + if constexpr (requires(Ts a) { a.view()->StringView; }) + return this->equals_ignoring_case(forward(strings.view())); + else + return this->equals_ignoring_case(forward(strings)); + }()); + } + private: friend class String; const char* m_characters { nullptr };