The main posixpp library and associated tests.
修订版 | b1b7172b600065fb0c3224f9a97f4350afb90803 (tree) |
---|---|
时间 | 2022-01-11 04:41:07 |
作者 | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
Merge with other clang-tidy cleanups.
@@ -4,18 +4,18 @@ | ||
4 | 4 | |
5 | 5 | class move_detector { |
6 | 6 | public: |
7 | - move_detector(move_detector &&other) { other.moved_from_ = true; } | |
7 | + move_detector(move_detector &&other) noexcept { other.moved_from_ = true; } | |
8 | 8 | move_detector(move_detector const &) = default; |
9 | 9 | move_detector() = default; |
10 | 10 | |
11 | - move_detector &operator =(move_detector &&other) { | |
11 | + move_detector &operator =(move_detector &&other) noexcept { | |
12 | 12 | other.moved_from_ = true; |
13 | 13 | return *this; |
14 | 14 | } |
15 | 15 | |
16 | 16 | move_detector &operator =(move_detector const &) = default; |
17 | 17 | |
18 | - bool was_moved_from() const { return moved_from_; } | |
18 | + [[nodiscard]] bool was_moved_from() const { return moved_from_; } | |
19 | 19 | |
20 | 20 | private: |
21 | 21 | bool moved_from_ = false; |
@@ -55,7 +55,7 @@ | ||
55 | 55 | CHECK_THROWS_AS(result.error(), ::posixpp::no_error_here); |
56 | 56 | } |
57 | 57 | } |
58 | - GIVEN("An expectedd<int> result initialized as an error with ENOENT") { | |
58 | + GIVEN("An expected<int> result initialized as an error with ENOENT") { | |
59 | 59 | using expected_t = ::posixpp::expected<int>; |
60 | 60 | expected_t const result{expected_t::err_tag{}, ENOENT}; |
61 | 61 | THEN(" result.result() throws ::std:system_error ") { |
@@ -106,11 +106,11 @@ | ||
106 | 106 | CHECK_FALSE(result.result().was_moved_from()); |
107 | 107 | } |
108 | 108 | THEN( " copying the result out doesn't move it.") { |
109 | - move_detector tmp{result.result()}; | |
109 | + [[maybe_unused]] move_detector tmp{result.result()}; | |
110 | 110 | CHECK_FALSE(result.result().was_moved_from()); |
111 | 111 | } |
112 | 112 | THEN( " returning it from a lambda also doesn't move it.") { |
113 | - auto result2 = [&result]() -> expected_t { return result; }(); | |
113 | + auto result2 = [&result]() -> expected_t { return result; }(); // NOLINT(performance-no-automatic-move) | |
114 | 114 | CHECK_FALSE(result.result().was_moved_from()); |
115 | 115 | } |
116 | 116 | } |
@@ -119,7 +119,7 @@ | ||
119 | 119 | expected_t result{cant_copy{}}; |
120 | 120 | THEN(" you can still get the result out.") { |
121 | 121 | // This is just a test to see if the code compiles. |
122 | - auto tmp = result.result(); | |
122 | + [[maybe_unused]] auto tmp = result.result(); | |
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |