net/UniqueSocketDescriptor: add method MoveToFileDescriptor()

This commit is contained in:
Max Kellermann 2024-03-20 09:30:29 +01:00 committed by Max Kellermann
parent d563f5fc87
commit 011b96ff98

View File

@ -5,6 +5,10 @@
#include "SocketDescriptor.hxx"
#ifndef _WIN32
#include "io/UniqueFileDescriptor.hxx"
#endif
#include <utility>
class StaticSocketAddress;
@ -47,6 +51,12 @@ public:
return std::exchange(*(SocketDescriptor *)this, Undefined());
}
#ifndef _WIN32
UniqueFileDescriptor MoveToFileDescriptor() && noexcept {
return UniqueFileDescriptor{Release().ToFileDescriptor()};
}
#endif
UniqueSocketDescriptor &operator=(UniqueSocketDescriptor &&src) noexcept {
using std::swap;
swap(fd, src.fd);