Browse Source

CharProxy: Add copy constructor

Adding the copy constructor is needed to solve a `-Wdeprecated-copy` warning
from GCC and Clang, which is raised when upgrading doctest from 2.4.4 to 2.4.6.

(cherry picked from commit cc57cbb73a4675f8b51e6cf4a77f0f9d814d4b01)
Rémi Verschelde 3 years ago
parent
commit
b960ab1cea
1 changed files with 10 additions and 6 deletions
  1. 10 6
      core/ustring.h

+ 10 - 6
core/ustring.h

@@ -45,11 +45,15 @@ class CharProxy {
 	CowData<T> &_cowdata;
 	CowData<T> &_cowdata;
 	static const T _null = 0;
 	static const T _null = 0;
 
 
-	_FORCE_INLINE_ CharProxy(const int &p_index, CowData<T> &cowdata) :
+	_FORCE_INLINE_ CharProxy(const int &p_index, CowData<T> &p_cowdata) :
 			_index(p_index),
 			_index(p_index),
-			_cowdata(cowdata) {}
+			_cowdata(p_cowdata) {}
 
 
 public:
 public:
+	_FORCE_INLINE_ CharProxy(const CharProxy<T> &p_other) :
+			_index(p_other._index),
+			_cowdata(p_other._cowdata) {}
+
 	_FORCE_INLINE_ operator T() const {
 	_FORCE_INLINE_ operator T() const {
 		if (unlikely(_index == _cowdata.size())) {
 		if (unlikely(_index == _cowdata.size())) {
 			return _null;
 			return _null;
@@ -62,12 +66,12 @@ public:
 		return _cowdata.ptr() + _index;
 		return _cowdata.ptr() + _index;
 	}
 	}
 
 
-	_FORCE_INLINE_ void operator=(const T &other) const {
-		_cowdata.set(_index, other);
+	_FORCE_INLINE_ void operator=(const T &p_other) const {
+		_cowdata.set(_index, p_other);
 	}
 	}
 
 
-	_FORCE_INLINE_ void operator=(const CharProxy<T> &other) const {
-		_cowdata.set(_index, other.operator T());
+	_FORCE_INLINE_ void operator=(const CharProxy<T> &p_other) const {
+		_cowdata.set(_index, p_other.operator T());
 	}
 	}
 };
 };