Просмотр исходного кода

AK+LibRegex: Disable construction of views from temporary Strings

Idan Horowitz 3 лет назад
Родитель
Сommit
e8f6840471
3 измененных файлов с 6 добавлено и 0 удалено
  1. 2 0
      AK/StringView.h
  2. 2 0
      AK/Utf8View.h
  3. 2 0
      Userland/Libraries/LibRegex/RegexMatch.h

+ 2 - 0
AK/StringView.h

@@ -48,6 +48,8 @@ public:
     StringView(const String&);
     StringView(const FlyString&);
 
+    explicit StringView(String&&) = delete;
+
     [[nodiscard]] constexpr bool is_null() const { return !m_characters; }
     [[nodiscard]] constexpr bool is_empty() const { return m_length == 0; }
 

+ 2 - 0
AK/Utf8View.h

@@ -58,6 +58,8 @@ public:
     explicit Utf8View(const char*);
     ~Utf8View() = default;
 
+    explicit Utf8View(String&&) = delete;
+
     const StringView& as_string() const { return m_string; }
 
     Utf8CodePointIterator begin() const;

+ 2 - 0
Userland/Libraries/LibRegex/RegexMatch.h

@@ -54,6 +54,8 @@ public:
     {
     }
 
+    explicit RegexStringView(String&&) = delete;
+
     StringView const& string_view() const
     {
         return m_view.get<StringView>();