43 DFX_ENABLE_DEFAULT_COPY_AND_MOVE_NOEXCEPT(
BorrowedFd);
47 bool operator==(
BorrowedFd const & fd) const noexcept {
return _fd == fd._fd; }
48 bool operator==(
int fd)
const noexcept {
return _fd == fd; }
53 int get() const noexcept {
return _fd; }
56 bool isValid() const noexcept {
return _fd != -1; }
60 void reset() noexcept { _fd = -1; }
66inline void swap(BorrowedFd & fd1, BorrowedFd & fd2)
noexcept { fd1.swap(fd2); }
70struct std::formatter<
dfx::Utils::BorrowedFd> :
public formatter<int>
73 {
return formatter<int>::format(e.
get(), ctx); }
77struct std::hash<
dfx::Utils::BorrowedFd>
80 {
return static_cast<std::size_t
>(fd.
get()); }
Convenience macros to explicitly control copy and move semantics.
Non-owning wrapper around a file descriptor.
Definition BorrowedFd.hpp:33
BorrowedFd() noexcept=default
Create an invalid BorrowedFd.
int get() const noexcept
Get the underlying file descriptor value.
Definition BorrowedFd.hpp:53
bool isValid() const noexcept
Check if the current BorrowedFd contains a valid fd.
Definition BorrowedFd.hpp:56
void reset() noexcept
Invalidate this BorrowedFd.
Definition BorrowedFd.hpp:60
Definition SystemConfigCommandHandler.hpp:15
Definition Message.hpp:21