diff options
author | Jon Atack <jon@atack.com> | 2022-04-28 13:33:57 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2022-04-28 20:34:43 +0200 |
commit | e5485e8e4be7f2ee0671f58c3dcce35c68ba0ee0 (patch) | |
tree | 0aa75159fb49606730d74080140f224ed4c8b01a /src/test/checkqueue_tests.cpp | |
parent | abc1ee509025d92db5311c3f5df3b61c09cad24f (diff) |
test, bench: make prevector and checkqueue swap member functions noexcept
Reason:
A swap must not fail; when a class has a swap member function, it should be declared noexcept.
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c84-a-swap-function-must-not-fail
Diffstat (limited to 'src/test/checkqueue_tests.cpp')
-rw-r--r-- | src/test/checkqueue_tests.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/test/checkqueue_tests.cpp b/src/test/checkqueue_tests.cpp index 0d95bd7670..79d6b94dff 100644 --- a/src/test/checkqueue_tests.cpp +++ b/src/test/checkqueue_tests.cpp @@ -42,7 +42,7 @@ struct FakeCheck { { return true; } - void swap(FakeCheck& x){}; + void swap(FakeCheck& x) noexcept {}; }; struct FakeCheckCheckCompletion { @@ -52,7 +52,7 @@ struct FakeCheckCheckCompletion { n_calls.fetch_add(1, std::memory_order_relaxed); return true; } - void swap(FakeCheckCheckCompletion& x){}; + void swap(FakeCheckCheckCompletion& x) noexcept {}; }; struct FailingCheck { @@ -63,7 +63,7 @@ struct FailingCheck { { return !fails; } - void swap(FailingCheck& x) + void swap(FailingCheck& x) noexcept { std::swap(fails, x.fails); }; @@ -81,7 +81,10 @@ struct UniqueCheck { results.insert(check_id); return true; } - void swap(UniqueCheck& x) { std::swap(x.check_id, check_id); }; + void swap(UniqueCheck& x) noexcept + { + std::swap(x.check_id, check_id); + }; }; @@ -109,7 +112,10 @@ struct MemoryCheck { { fake_allocated_memory.fetch_sub(b, std::memory_order_relaxed); }; - void swap(MemoryCheck& x) { std::swap(b, x.b); }; + void swap(MemoryCheck& x) noexcept + { + std::swap(b, x.b); + }; }; struct FrozenCleanupCheck { @@ -133,7 +139,10 @@ struct FrozenCleanupCheck { cv.wait(l, []{ return nFrozen.load(std::memory_order_relaxed) == 0;}); } } - void swap(FrozenCleanupCheck& x){std::swap(should_freeze, x.should_freeze);}; + void swap(FrozenCleanupCheck& x) noexcept + { + std::swap(should_freeze, x.should_freeze); + }; }; // Static Allocations |