Skip to content

Commit

Permalink
Explicitly define move constructors and move assignment constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallardo994 committed Mar 16, 2024
1 parent 669ebb1 commit 22b448b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions imkcpp/include/segment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ namespace imkcpp {
this->assign(buf.subspan(offset, length));
offset += length;
}

SegmentData(SegmentData&& other) noexcept {
this->data = std::move(other.data);
}

SegmentData& operator=(SegmentData&& other) noexcept {
this->data = std::move(other.data);
return *this;
}
};

struct Segment final {
Expand All @@ -139,5 +148,18 @@ namespace imkcpp {
this->data.assign(buf);
this->header.len = PayloadLen(buf.size());
}

Segment(Segment&& other) noexcept {
this->header = other.header;
this->data = std::move(other.data);
this->metadata = other.metadata;
}

Segment& operator=(Segment&& other) noexcept {
this->header = other.header;
this->data = std::move(other.data);
this->metadata = other.metadata;
return *this;
}
};
}

0 comments on commit 22b448b

Please sign in to comment.