diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-10-28 01:28:11 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-29 11:53:01 +0100 |
commit | f0e59f2dac46c9d30c761d73d34ea5b29443a810 (patch) | |
tree | 570a7c9a42e930b528c5f108fa918e83ebb9711d /AK/StringView.h | |
parent | f4b7a688b1cda6d279936a2592149b612b8d8ca9 (diff) | |
download | serenity-f0e59f2dac46c9d30c761d73d34ea5b29443a810.zip |
AK: Add a `is_one_of()' to StringView
This copies the similar API from String.
Diffstat (limited to 'AK/StringView.h')
-rw-r--r-- | AK/StringView.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/AK/StringView.h b/AK/StringView.h index 5cdf7285f7..84d610ce23 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<typename T, typename... Rest> + 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 }; |