Commit db179d7 Swagtoy
committed
1 parent 248058e commit db179d7 Copy full SHA for db179d7
File tree 1 file changed +16
-12
lines changed
1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -166,26 +166,30 @@ class string
166
166
}
167
167
168
168
// ! Assignment operator for strings, ASCII and Unicode
169
- template <class B , std:: enable_if_t <std::is_array_v<B[]>, bool > = true >
169
+ template <class B >
170
170
string<T> &operator =(const B * c)
171
171
{
172
172
if (!c) {
173
173
clear ();
174
174
return *this ;
175
175
}
176
176
177
- _IRR_DEBUG_BREAK_IF (
178
- reinterpret_cast <uintptr_t >(c) >= (uintptr_t )(str.data ()) &&
179
- reinterpret_cast <uintptr_t >(c) < (uintptr_t )(str.data ()) + str.size ());
180
-
181
- u32 len = calclen (c);
182
- // In case `c` is a pointer to our own buffer, we may not resize first
183
- // or it can become invalid.
184
- if (len > str.size ()) str.resize (len);
185
- for (u32 l = 0 ; l < len; ++l)
186
- str[l] = static_cast <T>(c[l]);
187
- if (len < str.size ()) str.resize (len);
177
+ if constexpr (sizeof (T) != sizeof (B)) {
178
+ _IRR_DEBUG_BREAK_IF (
179
+ (uintptr_t )c >= (uintptr_t )(str.data ()) &&
180
+ (uintptr_t )c < (uintptr_t )(str.data () + str.size ()));
181
+ }
188
182
183
+ u32 len = calclen (c);
184
+ // In case `c` is a pointer to our own buffer, we may not resize first
185
+ // or it can become invalid.
186
+ if (len > str.size ())
187
+ str.resize (len);
188
+ for (u32 l = 0 ; l < len; ++l)
189
+ str[l] = static_cast <T>(c[l]);
190
+ if (len < str.size ())
191
+ str.resize (len);
192
+
189
193
return *this ;
190
194
}
191
195
You can’t perform that action at this time.
0 commit comments