[ox] Correct bad bit_cast uses and improve constexpr-ness

This commit is contained in:
2021-11-28 21:03:29 -06:00
parent 22f08f83c5
commit 1f24912ddd
35 changed files with 247 additions and 214 deletions

View File

@@ -11,6 +11,7 @@
#include <ox/std/defines.hpp>
#include <ox/std/error.hpp>
#include <ox/std/memory.hpp>
#include <ox/std/trace.hpp>
#include <ox/std/vector.hpp>
namespace ox {
@@ -44,7 +45,8 @@ class Signal {
virtual ~BaseSlot() = default;
virtual void call(Args...) = 0;
virtual void cleanup(Signal*) noexcept {}
virtual const void *receiver() noexcept { return nullptr; }
[[nodiscard]]
virtual const void *receiver() const noexcept { return nullptr; }
};
template<typename F>
@@ -86,7 +88,8 @@ class Signal {
oxIgnoreError(m_receiver->destruction.disconnectSignal(signal));
}
const void *receiver() noexcept final {
[[nodiscard]]
const void *receiver() const noexcept final {
return m_receiver;
}
};
@@ -112,7 +115,8 @@ class Signal {
void cleanup(Signal*) noexcept final {
}
const void *receiver() noexcept final {
[[nodiscard]]
const void *receiver() const noexcept final {
return m_receiver;
}
};
@@ -228,7 +232,8 @@ class Signal<Error(Args...)> {
virtual ~BaseSlot() = default;
virtual Error call(Args...) noexcept = 0;
virtual void cleanup(Signal*) noexcept {}
virtual const void *receiver() noexcept { return nullptr; }
[[nodiscard]]
virtual const void *receiver() const noexcept { return nullptr; }
};
struct FunctionSlot: public BaseSlot {
@@ -261,7 +266,8 @@ class Signal<Error(Args...)> {
oxIgnoreError(m_receiver->destruction.disconnectSignal(signal));
}
const void *receiver() noexcept final {
[[nodiscard]]
const void *receiver() const noexcept final {
return m_receiver;
}
};
@@ -283,7 +289,8 @@ class Signal<Error(Args...)> {
void cleanup(Signal*) noexcept final {
}
const void *receiver() noexcept final {
[[nodiscard]]
const void *receiver() const noexcept final {
return m_receiver;
}
};