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 1836a5f commit d70832d
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 d70832d

Please sign in to comment.