diff --git a/Sources/ComputeCxx/Comparison/Compare.cpp b/Sources/ComputeCxx/Comparison/Compare.cpp index c88afa9..881d174 100644 --- a/Sources/ComputeCxx/Comparison/Compare.cpp +++ b/Sources/ComputeCxx/Comparison/Compare.cpp @@ -49,6 +49,10 @@ Compare::Enum::~Enum() { } } +Compare::Frame::Frame(vector *enums): _enums(enums), _start(enums->size()) { + +} + Compare::Frame::~Frame() { while (_enums->size() > _start) { _enums->pop_back(); @@ -57,6 +61,8 @@ Compare::Frame::~Frame() { bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t offset, size_t size, AGComparisonOptions options) { + Frame frame = Frame(&_enums); + size_t end = size < 0 ? ~0 : offset + size; ValueLayoutReader reader = ValueLayoutReader(layout); diff --git a/Sources/ComputeCxx/Comparison/Compare.h b/Sources/ComputeCxx/Comparison/Compare.h index 1c71a47..5dfef3a 100644 --- a/Sources/ComputeCxx/Comparison/Compare.h +++ b/Sources/ComputeCxx/Comparison/Compare.h @@ -51,6 +51,7 @@ class Compare { uint64_t _start; public: + Frame(vector *enums); ~Frame(); }; diff --git a/Sources/ComputeCxx/Vector/Vector.h b/Sources/ComputeCxx/Vector/Vector.h index df37c8e..911a506 100644 --- a/Sources/ComputeCxx/Vector/Vector.h +++ b/Sources/ComputeCxx/Vector/Vector.h @@ -49,8 +49,8 @@ class vector { // Move - vector(vector &&); - vector &operator=(vector &&); + vector(vector &&) noexcept; + vector &operator=(vector &&) noexcept; // Element access @@ -162,6 +162,50 @@ vector::~vector() { } } +template + requires std::unsigned_integral +vector::vector(vector &&other) noexcept + : _size(std::exchange(other._size, 0)), _capacity(std::exchange(other._capacity, _inline_capacity)) { + if (other._buffer) { + _buffer = std::exchange(other._buffer, nullptr); + } else { + for (auto i = 0; i < _size; ++i) { + new (&_inline_buffer[i]) T(std::move(other._inline_buffer[i])); + other._inline_buffer[i].~T(); + } + _buffer = nullptr; + } +} + +template + requires std::unsigned_integral +vector &vector::operator=(vector &&other) noexcept { + if (this != &other) { + for (auto i = 0; i < _size; i++) { + data()[i].~T(); + } + if (_buffer) { + free(_buffer); + } + if (other._buffer) { + _buffer = std::exchange(other._buffer, nullptr); + _size = other._size; + _capacity = other._capacity; + } else { + for (auto i = 0; i < other._size; ++i) { + new (&_inline_buffer[i]) T(std::move(other._inline_buffer[i])); + other._inline_buffer[i].~T(); + } + _buffer = nullptr; + _size = other._size; + _capacity = other._capacity; + } + other._size = 0; + other._capacity = _inline_capacity; + } + return *this; +} + template requires std::unsigned_integral void vector::reserve_slow(size_type new_cap) {