Added support for completely disabling noexcept using MIJIN_TEST_NO_NOEXCEPT (for testing).
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user