Skip to content

Commit

Permalink
添加赋值运算,修复部分bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aurshine committed Nov 23, 2024
1 parent a5f4528 commit 928280a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aurshine/ayr/Dynarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ namespace ayr
self& operator=(const self& other)
{
if (this == &other) return *this;
ayr_destroy(blocks_);
ayr_destroy(&blocks_);

return *ayr_construct(this, other);
}

self& operator=(self&& other) noexcept
{
if (this == &other) return *this;
ayr_destroy(blocks_);
ayr_destroy(&blocks_);

return *ayr_construct(this, std::move(other));
}
Expand Down Expand Up @@ -180,6 +180,8 @@ namespace ayr

using const_reference = const value_type&;

_Iterator() : _Iterator(nullptr) {}

_Iterator(Container_t* dynarray) : _Iterator(dynarray, 0, 0) {}

_Iterator(Container_t* dynarray, c_size block_index, c_size inblock_index)
Expand Down
28 changes: 28 additions & 0 deletions aurshine/ayr/detail/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ namespace ayr
size_ = 0;
};

self& operator=(const self& other)
{
if (this == &other)
return *this;

ayr_destroy(arr_, size_);
ayr_delloc(arr_);

return *ayr_construct(this, other);;
}

self& operator=(self&& other) noexcept
{
if (this == &other)
return *this;

ayr_destroy(arr_, size_);
ayr_delloc(arr_);

size_ = other.size_;
arr_ = std::move(other.arr_);

other.size_ = 0;
other.arr_ = 0;

return *this;
}

T* data() { return arr_; }

const T* data() const { return arr_; }
Expand Down
16 changes: 16 additions & 0 deletions aurshine/ayr/detail/HashBucket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ namespace ayr

RobinHashBucket(RobinHashBucket&& other) noexcept : robin_managers_(std::move(other.robin_managers_)) {}

self& operator=(const self& other)
{
if (this == &other) return *this;

robin_managers_ = other.robin_managers_;
return *this;
}

self& operator=(self&& other) noexcept
{
if (this == &other) return *this;

robin_managers_ = std::move(other.robin_managers_);
return *this;
}

c_size capacity() const override { return robin_managers_.size(); }

self* clone() const override { return new self(*this); }
Expand Down

0 comments on commit 928280a

Please sign in to comment.