| 161 | TEST_CASE("just works with types with throwing move", "[factories][just]") |
| 162 | { |
| 163 | struct throwing_move |
| 164 | { |
| 165 | explicit throwing_move(std::size_t& throws_after) noexcept |
| 166 | : throws_after_(throws_after) |
| 167 | {} |
| 168 | |
| 169 | throwing_move(throwing_move&& other) // NOLINT(bugprone-exception-escape) |
| 170 | : throws_after_(other.throws_after_) |
| 171 | { |
| 172 | if (throws_after_) |
| 173 | { |
| 174 | --throws_after_; |
| 175 | } |
| 176 | else |
| 177 | { |
| 178 | throw std::runtime_error("Throwing as requested"); |
| 179 | } |
| 180 | } |
| 181 | private: |
| 182 | std::size_t& throws_after_; |
| 183 | }; |
| 184 | |
| 185 | std::size_t throws_after = 0; |
| 186 | auto const repeat_until_succeeds = [&](auto f) noexcept -> decltype(auto) |