Added support for completely disabling noexcept using MIJIN_TEST_NO_NOEXCEPT (for testing).

This commit is contained in:
2024-08-29 00:01:23 +02:00
parent a43f92fb58
commit 9ba097fc2f
41 changed files with 643 additions and 564 deletions

View File

@@ -10,6 +10,7 @@
#include <memory>
#include <mutex>
#include <vector>
#include "../internal/common.hpp"
#include "../util/flag.hpp"
namespace mijin
@@ -54,17 +55,17 @@ private:
public:
Signal() = default;
Signal(const Signal&) = delete;
Signal(Signal&&) noexcept = default;
Signal(Signal&&) MIJIN_NOEXCEPT = default;
public:
Signal& operator=(const Signal&) = delete;
Signal& operator=(Signal&&) noexcept = default;
Signal& operator=(Signal&&) MIJIN_NOEXCEPT = default;
public:
template<typename THandler, typename TWeak = void>
inline token_t connect(THandler handler, Oneshot oneshot = Oneshot::NO, std::weak_ptr<TWeak> referenced = std::weak_ptr<TWeak>()) noexcept;
inline token_t connect(THandler handler, Oneshot oneshot = Oneshot::NO, std::weak_ptr<TWeak> referenced = std::weak_ptr<TWeak>()) MIJIN_NOEXCEPT;
template<typename TObject, typename TWeak = void>
inline token_t connect(TObject& object, void (TObject::* handler)(TArgs...), Oneshot oneshot = Oneshot::NO, std::weak_ptr<TWeak> referenced = std::weak_ptr<TWeak>()) noexcept;
inline void disconnect(token_t token) noexcept;
inline void emit(TArgs&&... args) noexcept;
inline token_t connect(TObject& object, void (TObject::* handler)(TArgs...), Oneshot oneshot = Oneshot::NO, std::weak_ptr<TWeak> referenced = std::weak_ptr<TWeak>()) MIJIN_NOEXCEPT;
inline void disconnect(token_t token) MIJIN_NOEXCEPT;
inline void emit(TArgs&&... args) MIJIN_NOEXCEPT;
};
//
@@ -73,7 +74,7 @@ public:
template<typename... TArgs>
template<typename THandler, typename TWeak>
inline auto Signal<TArgs...>::connect(THandler handler, Oneshot oneshot, std::weak_ptr<TWeak> referenced) noexcept -> token_t
inline auto Signal<TArgs...>::connect(THandler handler, Oneshot oneshot, std::weak_ptr<TWeak> referenced) MIJIN_NOEXCEPT -> token_t
{
std::lock_guard lock(handlersMutex_);
@@ -90,7 +91,7 @@ inline auto Signal<TArgs...>::connect(THandler handler, Oneshot oneshot, std::we
template<typename... TArgs>
template<typename TObject, typename TWeak>
inline auto Signal<TArgs...>::connect(TObject& object, void (TObject::* handler)(TArgs...), Oneshot oneshot, std::weak_ptr<TWeak> referenced) noexcept -> token_t
inline auto Signal<TArgs...>::connect(TObject& object, void (TObject::* handler)(TArgs...), Oneshot oneshot, std::weak_ptr<TWeak> referenced) MIJIN_NOEXCEPT -> token_t
{
std::lock_guard lock(handlersMutex_);
@@ -109,7 +110,7 @@ inline auto Signal<TArgs...>::connect(TObject& object, void (TObject::* handler)
}
template<typename... TArgs>
inline void Signal<TArgs...>::disconnect(token_t token) noexcept
inline void Signal<TArgs...>::disconnect(token_t token) MIJIN_NOEXCEPT
{
std::lock_guard lock(handlersMutex_);
@@ -121,7 +122,7 @@ inline void Signal<TArgs...>::disconnect(token_t token) noexcept
}
template<typename... TArgs>
inline void Signal<TArgs...>::emit(TArgs&&... args) noexcept
inline void Signal<TArgs...>::emit(TArgs&&... args) MIJIN_NOEXCEPT
{
std::lock_guard lock(handlersMutex_);