Skip to content

Commit

Permalink
implement move operations for process_io_binding and delete copy op…
Browse files Browse the repository at this point in the history
…erations

This makes the test added in the previous commit pass.
  • Loading branch information
jgreitemann authored and klemens-morgenstern committed Jan 13, 2025
1 parent 4bb8425 commit e842a06
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions include/boost/process/v2/stdio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,31 @@ struct process_io_binding
}

process_io_binding() = default;
process_io_binding(const process_io_binding &) = delete;
process_io_binding & operator=(const process_io_binding &) = delete;

process_io_binding(process_io_binding && other) noexcept
: fd(other.fd), fd_needs_closing(other.fd), ec(other.ec)
{
other.fd = target;
other.fd_needs_closing = false;
other.ec = {};
}

process_io_binding & operator=(process_io_binding && other) noexcept
{
if (fd_needs_closing)
::close(fd);

fd = other.fd;
fd_needs_closing = other.fd_needs_closing;
ec = other.ec;

other.fd = target;
other.fd_needs_closing = false;
other.ec = {};
return *this;
}

template<typename Stream>
process_io_binding(Stream && str, decltype(std::declval<Stream>().native_handle()) * = nullptr)
Expand Down

0 comments on commit e842a06

Please sign in to comment.