|
| | OwnedFd () noexcept |
| | Create an invalid OwnedFd.
|
| | OwnedFd (int fd) noexcept |
| | Take ownership of a file descriptor.
|
| | OwnedFd (OwnedFd &&other) noexcept |
| | Move constructor.
|
|
| DISABLE_COPY (OwnedFd) |
| | ~OwnedFd () |
| | Destroy the OwnedFd and close the file descriptor if valid.
|
| OwnedFd & | operator= (OwnedFd &&other) noexcept |
| | Move assignment operator.
|
|
bool | operator== (OwnedFd const &) const noexcept=delete |
|
bool | operator!= (OwnedFd const &) const noexcept=delete |
|
bool | operator== (int fd) const noexcept |
|
bool | operator== (BorrowedFd const &fd) const noexcept |
|
void | swap (OwnedFd &other) noexcept |
| bool | isValid () const noexcept |
| | Check if this object owns a valid file descriptor.
|
| int | get () const noexcept |
| | Get the owned file descriptor.
|
| void | close () noexcept |
| | Close the owned file descriptor.
|
| int | release () noexcept |
| | Release ownership of the file descriptor.
|
| void | reset (int newFd=-1) noexcept |
| | Replace the owned file descriptor.
|
| BorrowedFd | borrow () const noexcept |
| | Create a non-owning view of the owned file descriptor.
|
Owning RAII wrapper around a file descriptor.
OwnedFd uniquely owns a file descriptor and is responsible for closing it. The descriptor is closed on destruction unless ownership has been released.
This type is move-only. Copying is disabled to enforce unique ownership.
An invalid OwnedFd is represented by a value of -1.
Ownership can be transferred via move construction or move assignment. Ownership can be explicitly released using release().
- See also
- BorrowedFd