template<typename T>
class HBData {
public:
HBData(T* other_data, size_t other_size, bool release) : data(other_data), size(other_size), isDeepCopy(release) {}
HBData(const HBData& other) {
if(isDeepCopy && data)
delete[] data;
data = new T[other.size];
auto len = sizeof(T) * other.size;
memcpy_s(data, len, other.data, len);
size = other.size;
isDeepCopy = true;
}
~HBData() {
if(isDeepCopy && data)
delete[] data;
}
public:
T* data = nullptr;
size_t size = 0;
bool isDeepCopy = false;
};