From abc1ee509025d92db5311c3f5df3b61c09cad24f Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Thu, 28 Apr 2022 20:20:30 +0200 Subject: [PATCH] validation: make CScriptCheck and prevector 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 --- src/prevector.h | 3 ++- src/validation.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/prevector.h b/src/prevector.h index aa20efaaa7..830b31e315 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -458,7 +458,8 @@ public: return *item_ptr(size() - 1); } - void swap(prevector& other) { + void swap(prevector& other) noexcept + { std::swap(_union, other._union); std::swap(_size, other._size); } diff --git a/src/validation.h b/src/validation.h index e3ea8617e7..afc53bb445 100644 --- a/src/validation.h +++ b/src/validation.h @@ -328,7 +328,8 @@ public: bool operator()(); - void swap(CScriptCheck &check) { + void swap(CScriptCheck& check) noexcept + { std::swap(ptxTo, check.ptxTo); std::swap(m_tx_out, check.m_tx_out); std::swap(nIn, check.nIn);