Make LocalVector -> Vector automatic conversion safe for non-trivial types.
This commit is contained in:
parent
89001f91d2
commit
0e32f3b957
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
Add a link
Reference in a new issue