Added support for completely disabling noexcept using MIJIN_TEST_NO_NOEXCEPT (for testing).
This commit is contained in:
@@ -8,8 +8,9 @@
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include "./signal.hpp"
|
||||
#include "../debug/assert.hpp"
|
||||
#include "../container/optional.hpp"
|
||||
#include "../debug/assert.hpp"
|
||||
#include "../internal/common.hpp"
|
||||
|
||||
namespace mijin
|
||||
{
|
||||
@@ -36,8 +37,8 @@ struct FutureStorage
|
||||
{
|
||||
Optional<TValue> value;
|
||||
|
||||
void setValue(TValue value_) noexcept { value = std::move(value_); }
|
||||
[[nodiscard]] TValue& getValue() noexcept { return value.get(); }
|
||||
void setValue(TValue value_) MIJIN_NOEXCEPT { value = std::move(value_); }
|
||||
[[nodiscard]] TValue& getValue() MIJIN_NOEXCEPT { return value.get(); }
|
||||
|
||||
};
|
||||
|
||||
@@ -46,8 +47,8 @@ struct FutureStorage
|
||||
// {
|
||||
// Optional<TValue*> value;
|
||||
//
|
||||
// void setValue(TValue& value_) noexcept { value = &value_; }
|
||||
// [[nodiscard]] TValue& getValue() const noexcept { return *value.get(); }
|
||||
// void setValue(TValue& value_) MIJIN_NOEXCEPT { value = &value_; }
|
||||
// [[nodiscard]] TValue& getValue() const MIJIN_NOEXCEPT { return *value.get(); }
|
||||
// };
|
||||
|
||||
template<>
|
||||
@@ -65,19 +66,19 @@ private:
|
||||
public:
|
||||
Future() = default;
|
||||
Future(const Future&) = delete;
|
||||
Future(Future&&) noexcept = default;
|
||||
Future(Future&&) MIJIN_NOEXCEPT = default;
|
||||
public:
|
||||
Future& operator=(const Future&) = delete;
|
||||
Future& operator=(Future&&) noexcept = default;
|
||||
Future& operator=(Future&&) MIJIN_NOEXCEPT = default;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr explicit operator bool() const noexcept { return ready(); }
|
||||
constexpr explicit operator bool() const MIJIN_NOEXCEPT { return ready(); }
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool operator!() const noexcept { return !ready(); }
|
||||
constexpr bool operator!() const MIJIN_NOEXCEPT { return !ready(); }
|
||||
public: // access
|
||||
[[nodiscard]]
|
||||
constexpr decltype(auto) get() noexcept
|
||||
constexpr decltype(auto) get() MIJIN_NOEXCEPT
|
||||
{
|
||||
MIJIN_ASSERT(isSet_, "Attempting to get from future that is not ready.");
|
||||
if constexpr(std::is_same_v<TValue, void>) {
|
||||
@@ -88,7 +89,7 @@ public: // access
|
||||
}
|
||||
}
|
||||
[[nodiscard]]
|
||||
constexpr decltype(auto) get() const noexcept
|
||||
constexpr decltype(auto) get() const MIJIN_NOEXCEPT
|
||||
{
|
||||
MIJIN_ASSERT(isSet_, "Attempting to get from future that is not ready.");
|
||||
if constexpr(std::is_same_v<TValue, void>) {
|
||||
@@ -99,20 +100,20 @@ public: // access
|
||||
}
|
||||
}
|
||||
[[nodiscard]]
|
||||
constexpr bool ready() const noexcept
|
||||
constexpr bool ready() const MIJIN_NOEXCEPT
|
||||
{
|
||||
return isSet_;
|
||||
}
|
||||
public: // modification
|
||||
template<typename TArg> requires (!std::is_same_v<TValue, void>)
|
||||
constexpr void set(TArg&& value) noexcept
|
||||
constexpr void set(TArg&& value) MIJIN_NOEXCEPT
|
||||
{
|
||||
MIJIN_ASSERT(!isSet_, "Trying to set a future twice!");
|
||||
value_.setValue(std::move(value));
|
||||
isSet_ = true;
|
||||
sigSet.emit();
|
||||
}
|
||||
constexpr void set() noexcept
|
||||
constexpr void set() MIJIN_NOEXCEPT
|
||||
{
|
||||
MIJIN_ASSERT(!isSet_, "Trying to set a future twice!");
|
||||
isSet_ = true;
|
||||
|
||||
Reference in New Issue
Block a user