[ox] Correct bad bit_cast uses and improve constexpr-ness
This commit is contained in:
19
deps/ox/src/ox/event/signal.hpp
vendored
19
deps/ox/src/ox/event/signal.hpp
vendored
@@ -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;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user