Skip to content

Commit

Permalink
ScopedFD - only use move semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Nov 13, 2024
1 parent e670154 commit 721c497
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crypto/test/file_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ class ScopedFD {
explicit ScopedFD(int fd) : fd_(fd) {}
~ScopedFD() { reset(); }

ScopedFD(ScopedFD &&other) { *this = std::move(other); }
ScopedFD &operator=(ScopedFD other) {
ScopedFD(ScopedFD &&other) noexcept { *this = std::move(other); }
ScopedFD &operator=(ScopedFD&& other) {
reset(other.release());
return *this;
}

ScopedFD(const ScopedFD &other) = delete;
ScopedFD &operator=(ScopedFD& other) = delete;

bool is_valid() const { return fd_ >= 0; }
int get() const { return fd_; }

Expand Down

0 comments on commit 721c497

Please sign in to comment.