The main posixpp library and associated tests.
修订版 | b1efa70ccb74a7bdc55c04be3801545e1bb7c91c (tree) |
---|---|
时间 | 2021-05-11 01:02:35 |
作者 | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
Move close to near top of member functions because it's important.
@@ -43,6 +43,15 @@ | ||
43 | 43 | return *this; |
44 | 44 | } |
45 | 45 | |
46 | + //! \brief Sets fd to invalid value and also calls close regardless of | |
47 | + //! whether fd is currently an invalid value. | |
48 | + [[nodiscard]] expected<void> close() noexcept { | |
49 | + using ::syscalls::linux::close; | |
50 | + auto const tmpfd = fd_; | |
51 | + fd_ = -1; | |
52 | + return close(tmpfd); | |
53 | + } | |
54 | + | |
46 | 55 | //! A true return value is maybe, a false return is definite. |
47 | 56 | [[nodiscard]] constexpr bool is_valid() const noexcept { |
48 | 57 | return fd_ >= 0; |
@@ -114,15 +123,6 @@ | ||
114 | 123 | } |
115 | 124 | //! @} |
116 | 125 | |
117 | - //! \brief Sets fd to invalid value and also calls close regardless of | |
118 | - //! whether fd is currently an invalid value. | |
119 | - [[nodiscard]] expected<void> close() noexcept { | |
120 | - using ::syscalls::linux::close; | |
121 | - auto const tmpfd = fd_; | |
122 | - fd_ = -1; | |
123 | - return close(tmpfd); | |
124 | - } | |
125 | - | |
126 | 126 | protected: |
127 | 127 | static fd int_to_fd(int fdes) noexcept { |
128 | 128 | return fd{fdes}; |