1 #include <boost/beast/core/file_posix.hpp> 2 3 struct DuplicatableFileHandle 4 { 5 boost::beast::file_posix fileHandle; 6 7 DuplicatableFileHandle() = default; 8 DuplicatableFileHandle(DuplicatableFileHandle&&) noexcept = default; 9 // Overload copy constructor, because posix doesn't have dup(), but linux 10 // does DuplicatableFileHandleDuplicatableFileHandle11 DuplicatableFileHandle(const DuplicatableFileHandle& other) 12 { 13 fileHandle.native_handle(dup(other.fileHandle.native_handle())); 14 } operator =DuplicatableFileHandle15 DuplicatableFileHandle& operator=(const DuplicatableFileHandle& other) 16 { 17 if (this == &other) 18 { 19 return *this; 20 } 21 fileHandle.native_handle(dup(other.fileHandle.native_handle())); 22 return *this; 23 } 24 DuplicatableFileHandle& 25 operator=(DuplicatableFileHandle&& other) noexcept = default; 26 ~DuplicatableFileHandle() = default; 27 }; 28