Kaynağa Gözat

Make sure Variant is not implicitely cast when using operator[]

Co-authored-by: Hein-Pieter van Braam-Stewart <[email protected]>
Gilles Roudière 4 yıl önce
ebeveyn
işleme
a825f955ab
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  1. 4 0
      core/variant/variant.h

+ 4 - 0
core/variant/variant.h

@@ -346,6 +346,10 @@ public:
 	bool is_one() const;
 	bool is_null() const;
 
+	// Make sure Variant is not implicitly cast when accessing it with bracket notation (GH-49469).
+	Variant &operator[](const Variant &p_key) = delete;
+	const Variant &operator[](const Variant &p_key) const = delete;
+
 	operator bool() const;
 	operator signed int() const;
 	operator unsigned int() const; // this is the real one