From 5f199821375667aaeb9f994956ee5d9c3431cc81 Mon Sep 17 00:00:00 2001 From: FranckRJ Date: Fri, 10 May 2024 15:46:06 +0200 Subject: [PATCH] Replaced noexcept by FAKEIT_NO_THROWS and removed useless defaulted special member functions for Mock. --- include/fakeit/Mock.hpp | 8 -------- include/fakeit/MockImpl.hpp | 2 +- include/mockutils/DynamicProxy.hpp | 2 +- include/mockutils/gcc/VirtualTable.hpp | 6 ++++-- include/mockutils/mscpp/VirtualTable.hpp | 6 ++++-- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/fakeit/Mock.hpp b/include/fakeit/Mock.hpp index 8e35ab09..fffde197 100644 --- a/include/fakeit/Mock.hpp +++ b/include/fakeit/Mock.hpp @@ -36,14 +36,6 @@ namespace fakeit { class Mock : public ActualInvocationsSource { MockImpl impl; public: - Mock(const Mock&) = delete; - Mock(Mock&&) noexcept = default; - - Mock& operator=(const Mock&) = delete; - Mock& operator=(Mock&&) = delete; - - ~Mock() override = default; - static_assert(std::is_polymorphic::value, "Can only mock a polymorphic type"); Mock() : impl(Fakeit) { diff --git a/include/fakeit/MockImpl.hpp b/include/fakeit/MockImpl.hpp index 8590cc4d..96eaa12f 100644 --- a/include/fakeit/MockImpl.hpp +++ b/include/fakeit/MockImpl.hpp @@ -37,7 +37,7 @@ namespace fakeit { } MockImpl(const MockImpl&) = delete; - MockImpl(MockImpl&& other) noexcept + MockImpl(MockImpl&& other) FAKEIT_NO_THROWS : _instanceOwner(std::move(other._instanceOwner)) , _proxy(std::move(other._proxy)) , _fakeit(other._fakeit) { diff --git a/include/mockutils/DynamicProxy.hpp b/include/mockutils/DynamicProxy.hpp index 76014f1d..2d562f23 100644 --- a/include/mockutils/DynamicProxy.hpp +++ b/include/mockutils/DynamicProxy.hpp @@ -70,7 +70,7 @@ namespace fakeit { } DynamicProxy(const DynamicProxy&) = delete; - DynamicProxy(DynamicProxy&& other) noexcept + DynamicProxy(DynamicProxy&& other) FAKEIT_NO_THROWS : _originalVt(std::move(other._originalVt)) , _methodMocks(std::move(other._methodMocks)) , _members(std::move(other._members)) diff --git a/include/mockutils/gcc/VirtualTable.hpp b/include/mockutils/gcc/VirtualTable.hpp index b1efb4fc..03891818 100644 --- a/include/mockutils/gcc/VirtualTable.hpp +++ b/include/mockutils/gcc/VirtualTable.hpp @@ -15,6 +15,8 @@ #endif +#include "mockutils/Macros.hpp" + namespace fakeit { struct VirtualTableBase { @@ -27,12 +29,12 @@ namespace fakeit { VirtualTableBase(void **firstMethod) : _firstMethod(firstMethod) { } VirtualTableBase(const VirtualTableBase&) = delete; - VirtualTableBase(VirtualTableBase&& other) noexcept { + VirtualTableBase(VirtualTableBase&& other) FAKEIT_NO_THROWS { std::swap(_firstMethod, other._firstMethod); } VirtualTableBase& operator=(const VirtualTableBase&) = delete; - VirtualTableBase& operator=(VirtualTableBase&& other) noexcept { + VirtualTableBase& operator=(VirtualTableBase&& other) FAKEIT_NO_THROWS { std::swap(_firstMethod, other._firstMethod); return *this; } diff --git a/include/mockutils/mscpp/VirtualTable.hpp b/include/mockutils/mscpp/VirtualTable.hpp index aa573755..0d57d241 100644 --- a/include/mockutils/mscpp/VirtualTable.hpp +++ b/include/mockutils/mscpp/VirtualTable.hpp @@ -10,6 +10,8 @@ #include #include +#include "mockutils/Macros.hpp" + namespace fakeit { typedef unsigned long dword_; @@ -188,13 +190,13 @@ namespace fakeit { } VirtualTable(const VirtualTable&) = delete; - VirtualTable(VirtualTable&& other) noexcept + VirtualTable(VirtualTable&& other) FAKEIT_NO_THROWS : VirtualTableBase(nullptr) { std::swap(_firstMethod, other._firstMethod); } VirtualTable& operator=(const VirtualTable&) = delete; - VirtualTable& operator=(VirtualTable&& other) noexcept { + VirtualTable& operator=(VirtualTable&& other) FAKEIT_NO_THROWS { std::swap(_firstMethod, other._firstMethod); return *this; }