summaryrefslogtreecommitdiff
path: root/AK/StringView.h
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-10-28 01:28:11 +0330
committerAndreas Kling <kling@serenityos.org>2020-10-29 11:53:01 +0100
commitf0e59f2dac46c9d30c761d73d34ea5b29443a810 (patch)
tree570a7c9a42e930b528c5f108fa918e83ebb9711d /AK/StringView.h
parentf4b7a688b1cda6d279936a2592149b612b8d8ca9 (diff)
downloadserenity-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.h10
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 };