View Single Post
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-04-2018 , 07:13   Re: [AMTL] Is there any way to clone a ke::Vector?
Reply With Quote #2

You have to copy it manually with iteration, the copy constructor isn't implemented for ke::Vector.
However if your item type is simple and can be copied just by copying bits (for example has no copy constructor with side effects, like primitive types), you can just memcpy it.
Code:
#include <cstring>

ke::Vector<int> a, b;
b.append(1);

a.ensure(b.length()); // Ensure that the underlying buffer is big enough
memcpy(a.buffer(), b.buffer(), b.length() * sizeof(int)); // Copy
__________________
klippy is offline