mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 11:03:13 -05:00
Merge pull request #100683 from Ivorforce/localvector-vector-conversion-typesafe-copy
Make `LocalVector` -> `Vector` automatic conversion safe for non-trivial types.
This commit is contained in:
commit
31c07776f4
1 changed files with 8 additions and 2 deletions
|
@ -295,10 +295,16 @@ public:
|
|||
|
||||
operator Vector<T>() const {
|
||||
Vector<T> ret;
|
||||
ret.resize(size());
|
||||
ret.resize(count);
|
||||
T *w = ret.ptrw();
|
||||
if (w) {
|
||||
memcpy(w, data, sizeof(T) * count);
|
||||
if constexpr (std::is_trivially_copyable_v<T>) {
|
||||
memcpy(w, data, sizeof(T) * count);
|
||||
} else {
|
||||
for (U i = 0; i < count; i++) {
|
||||
w[i] = data[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue