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

@@ -7,6 +7,7 @@
#include <cstdint>
#include "./traits.hpp"
#include "./types.hpp"
#include "../internal/common.hpp"
namespace mijin
{
@@ -15,23 +16,23 @@ namespace mijin
// public defines
//
#define MIJIN_DEFINE_FLAG(name) \
struct name : mijin::Flag \
{ \
private: \
struct Proxy_ { \
uint8_t value; \
}; \
public: \
constexpr name() = default; \
constexpr name(const name&) = default; \
constexpr name(Proxy_ proxy) \
: Flag(proxy.value) {} \
constexpr explicit name(bool value) noexcept \
: Flag(value) {} \
name& operator=(const name&) = default; \
static constexpr Proxy_ YES{1}; \
static constexpr Proxy_ NO{0}; \
#define MIJIN_DEFINE_FLAG(name) \
struct name : mijin::Flag \
{ \
private: \
struct Proxy_ { \
uint8_t value; \
}; \
public: \
constexpr name() = default; \
constexpr name(const name&) = default; \
constexpr name(Proxy_ proxy) MIJIN_NOEXCEPT \
: Flag(proxy.value) {} \
constexpr explicit name(bool value) MIJIN_NOEXCEPT \
: Flag(value) {} \
name& operator=(const name&) = default; \
static constexpr Proxy_ YES{1}; \
static constexpr Proxy_ NO{0}; \
}
//
@@ -48,23 +49,23 @@ struct Flag
Flag() = default;
Flag(const Flag&) = default;
explicit constexpr Flag(uint8_t value) noexcept : value(value) {}
explicit constexpr Flag(uint8_t value) MIJIN_NOEXCEPT : value(value) {}
Flag& operator=(const Flag&) = default;
constexpr bool operator ==(const Flag& other) const noexcept
constexpr bool operator ==(const Flag& other) const MIJIN_NOEXCEPT
{
return value == other.value;
}
constexpr bool operator !=(const Flag& other) const noexcept
constexpr bool operator !=(const Flag& other) const MIJIN_NOEXCEPT
{
return value != other.value;
}
constexpr bool operator !() const noexcept
constexpr bool operator !() const MIJIN_NOEXCEPT
{
return !value;
}
constexpr operator bool() const noexcept
constexpr operator bool() const MIJIN_NOEXCEPT
{
return value != 0;
}
@@ -89,7 +90,7 @@ private:
using base_t = FlagSetStorage<offset + 1, TMore...>;
static constexpr typename base_t::data_t BIT = (1 << offset);
public:
constexpr void set(TFirst value) noexcept
constexpr void set(TFirst value) MIJIN_NOEXCEPT
{
if (value)
{
@@ -100,7 +101,7 @@ public:
base_t::data_ &= ~BIT;
}
}
constexpr bool get(TFirst) noexcept
constexpr bool get(TFirst) MIJIN_NOEXCEPT
{
return (base_t::data_ & BIT) != 0;
}
@@ -134,19 +135,19 @@ public:
public:
FlagSet& operator=(const FlagSet&) = default;
template<FlagType T> requires is_any_type_v<T, TFlags...>
FlagSet& operator=(T flag) noexcept
FlagSet& operator=(T flag) MIJIN_NOEXCEPT
{
reset(flag);
return *this;
}
template<FlagType T> requires is_any_type_v<T, TFlags...>
FlagSet& operator|=(T flag) noexcept
FlagSet& operator|=(T flag) MIJIN_NOEXCEPT
{
set(flag);
return *this;
}
template<FlagType T> requires is_any_type_v<T, TFlags...>
FlagSet& operator&=(T flag) noexcept
FlagSet& operator&=(T flag) MIJIN_NOEXCEPT
{
unset(flag);
}