From f0e59f2dac46c9d30c761d73d34ea5b29443a810 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Wed, 28 Oct 2020 01:28:11 +0330 Subject: [PATCH] AK: Add a `is_one_of()' to StringView This copies the similar API from String. --- AK/StringView.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AK/StringView.h b/AK/StringView.h index 5cdf7285f7f..84d610ce231 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -180,7 +180,17 @@ public: const char* begin() { return m_characters; } const char* end() { return m_characters + m_length; } + template + bool is_one_of(const T& string, Rest... rest) const + { + if (*this == string) + return true; + return is_one_of(rest...); + } + private: + bool is_one_of() const { return false; } + friend class String; const StringImpl* m_impl { nullptr }; const char* m_characters { nullptr };