signal: prepare to remove ENTT_NOEXCEPT[_IF]

This commit is contained in:
Michele Caini
2022-05-06 08:23:42 +02:00
parent 2065c4294f
commit 942879bbba
4 changed files with 42 additions and 45 deletions

View File

@@ -81,7 +81,7 @@ class delegate;
template<typename Ret, typename... Args>
class delegate<Ret(Args...)> {
template<auto Candidate, std::size_t... Index>
[[nodiscard]] auto wrap(std::index_sequence<Index...>) ENTT_NOEXCEPT {
[[nodiscard]] auto wrap(std::index_sequence<Index...>) noexcept {
return [](const void *, Args... args) -> Ret {
[[maybe_unused]] const auto arguments = std::forward_as_tuple(std::forward<Args>(args)...);
return static_cast<Ret>(std::invoke(Candidate, std::forward<type_list_element_t<Index, type_list<Args...>>>(std::get<Index>(arguments))...));
@@ -89,7 +89,7 @@ class delegate<Ret(Args...)> {
}
template<auto Candidate, typename Type, std::size_t... Index>
[[nodiscard]] auto wrap(Type &, std::index_sequence<Index...>) ENTT_NOEXCEPT {
[[nodiscard]] auto wrap(Type &, std::index_sequence<Index...>) noexcept {
return [](const void *payload, Args... args) -> Ret {
[[maybe_unused]] const auto arguments = std::forward_as_tuple(std::forward<Args>(args)...);
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
@@ -98,7 +98,7 @@ class delegate<Ret(Args...)> {
}
template<auto Candidate, typename Type, std::size_t... Index>
[[nodiscard]] auto wrap(Type *, std::index_sequence<Index...>) ENTT_NOEXCEPT {
[[nodiscard]] auto wrap(Type *, std::index_sequence<Index...>) noexcept {
return [](const void *payload, Args... args) -> Ret {
[[maybe_unused]] const auto arguments = std::forward_as_tuple(std::forward<Args>(args)...);
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
@@ -115,7 +115,7 @@ public:
using result_type = Ret;
/*! @brief Default constructor. */
delegate() ENTT_NOEXCEPT
delegate() noexcept
: instance{nullptr},
fn{nullptr} {}
@@ -126,7 +126,7 @@ public:
* @param value_or_instance Optional valid object that fits the purpose.
*/
template<auto Candidate, typename... Type>
delegate(connect_arg_t<Candidate>, Type &&...value_or_instance) ENTT_NOEXCEPT {
delegate(connect_arg_t<Candidate>, Type &&...value_or_instance) noexcept {
connect<Candidate>(std::forward<Type>(value_or_instance)...);
}
@@ -136,7 +136,7 @@ public:
* @param function Function to connect to the delegate.
* @param payload User defined arbitrary data.
*/
delegate(function_type *function, const void *payload = nullptr) ENTT_NOEXCEPT {
delegate(function_type *function, const void *payload = nullptr) noexcept {
connect(function, payload);
}
@@ -145,7 +145,7 @@ public:
* @tparam Candidate Function or member to connect to the delegate.
*/
template<auto Candidate>
void connect() ENTT_NOEXCEPT {
void connect() noexcept {
instance = nullptr;
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
@@ -175,7 +175,7 @@ public:
* @param value_or_instance A valid reference that fits the purpose.
*/
template<auto Candidate, typename Type>
void connect(Type &value_or_instance) ENTT_NOEXCEPT {
void connect(Type &value_or_instance) noexcept {
instance = &value_or_instance;
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Type &, Args...>) {
@@ -199,7 +199,7 @@ public:
* @param value_or_instance A valid pointer that fits the purpose.
*/
template<auto Candidate, typename Type>
void connect(Type *value_or_instance) ENTT_NOEXCEPT {
void connect(Type *value_or_instance) noexcept {
instance = value_or_instance;
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Type *, Args...>) {
@@ -225,7 +225,7 @@ public:
* @param function Function to connect to the delegate.
* @param payload User defined arbitrary data.
*/
void connect(function_type *function, const void *payload = nullptr) ENTT_NOEXCEPT {
void connect(function_type *function, const void *payload = nullptr) noexcept {
instance = payload;
fn = function;
}
@@ -235,7 +235,7 @@ public:
*
* After a reset, a delegate cannot be invoked anymore.
*/
void reset() ENTT_NOEXCEPT {
void reset() noexcept {
instance = nullptr;
fn = nullptr;
}
@@ -244,7 +244,7 @@ public:
* @brief Returns the instance or the payload linked to a delegate, if any.
* @return An opaque pointer to the underlying data.
*/
[[nodiscard]] const void *data() const ENTT_NOEXCEPT {
[[nodiscard]] const void *data() const noexcept {
return instance;
}
@@ -269,7 +269,7 @@ public:
* @brief Checks whether a delegate actually stores a listener.
* @return False if the delegate is empty, true otherwise.
*/
[[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
[[nodiscard]] explicit operator bool() const noexcept {
// no need to also test instance
return !(fn == nullptr);
}
@@ -279,7 +279,7 @@ public:
* @param other Delegate with which to compare.
* @return False if the two contents differ, true otherwise.
*/
[[nodiscard]] bool operator==(const delegate<Ret(Args...)> &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const delegate<Ret(Args...)> &other) const noexcept {
return fn == other.fn && instance == other.instance;
}
@@ -297,7 +297,7 @@ private:
* @return True if the two contents differ, false otherwise.
*/
template<typename Ret, typename... Args>
[[nodiscard]] bool operator!=(const delegate<Ret(Args...)> &lhs, const delegate<Ret(Args...)> &rhs) ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const delegate<Ret(Args...)> &lhs, const delegate<Ret(Args...)> &rhs) noexcept {
return !(lhs == rhs);
}

View File

@@ -7,7 +7,6 @@
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_map.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/fwd.hpp"
@@ -29,8 +28,8 @@ struct basic_dispatcher_handler {
virtual ~basic_dispatcher_handler() = default;
virtual void publish() = 0;
virtual void disconnect(void *) = 0;
virtual void clear() ENTT_NOEXCEPT = 0;
virtual std::size_t size() const ENTT_NOEXCEPT = 0;
virtual void clear() noexcept = 0;
virtual std::size_t size() const noexcept = 0;
};
template<typename Type, typename Allocator>
@@ -62,11 +61,11 @@ public:
bucket().disconnect(instance);
}
void clear() ENTT_NOEXCEPT override {
void clear() noexcept override {
events.clear();
}
[[nodiscard]] auto bucket() ENTT_NOEXCEPT {
[[nodiscard]] auto bucket() noexcept {
return typename signal_type::sink_type{signal};
}
@@ -83,7 +82,7 @@ public:
}
}
std::size_t size() const ENTT_NOEXCEPT override {
std::size_t size() const noexcept override {
return events.size();
}
@@ -172,7 +171,7 @@ public:
* @brief Move constructor.
* @param other The instance to move from.
*/
basic_dispatcher(basic_dispatcher &&other) ENTT_NOEXCEPT
basic_dispatcher(basic_dispatcher &&other) noexcept
: pools{std::move(other.pools)} {}
/**
@@ -180,7 +179,7 @@ public:
* @param other The instance to move from.
* @param allocator The allocator to use.
*/
basic_dispatcher(basic_dispatcher &&other, const allocator_type &allocator) ENTT_NOEXCEPT
basic_dispatcher(basic_dispatcher &&other, const allocator_type &allocator) noexcept
: pools{container_type{std::move(other.pools.first()), allocator}, allocator} {}
/**
@@ -188,7 +187,7 @@ public:
* @param other The instance to move from.
* @return This dispatcher.
*/
basic_dispatcher &operator=(basic_dispatcher &&other) ENTT_NOEXCEPT {
basic_dispatcher &operator=(basic_dispatcher &&other) noexcept {
pools = std::move(other.pools);
return *this;
}
@@ -206,7 +205,7 @@ public:
* @brief Returns the associated allocator.
* @return The associated allocator.
*/
[[nodiscard]] constexpr allocator_type get_allocator() const ENTT_NOEXCEPT {
[[nodiscard]] constexpr allocator_type get_allocator() const noexcept {
return pools.second();
}
@@ -217,7 +216,7 @@ public:
* @return The number of pending events for the given type.
*/
template<typename Type>
size_type size(const id_type id = type_hash<Type>::value()) const ENTT_NOEXCEPT {
size_type size(const id_type id = type_hash<Type>::value()) const noexcept {
const auto *cpool = assure<Type>(id);
return cpool ? cpool->size() : 0u;
}
@@ -226,7 +225,7 @@ public:
* @brief Returns the total number of pending events.
* @return The total number of pending events.
*/
size_type size() const ENTT_NOEXCEPT {
size_type size() const noexcept {
size_type count{};
for(auto &&cpool: pools.first()) {
@@ -360,7 +359,7 @@ public:
}
/*! @brief Discards all the events queued so far. */
void clear() ENTT_NOEXCEPT {
void clear() noexcept {
for(auto &&cpool: pools.first()) {
cpool.second->clear();
}

View File

@@ -5,7 +5,6 @@
#include <memory>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../container/dense_map.hpp"
#include "../core/fwd.hpp"
#include "../core/type_info.hpp"
@@ -61,7 +60,7 @@ public:
: handlers{} {}
/*! @brief Default destructor. */
virtual ~emitter() ENTT_NOEXCEPT {
virtual ~emitter() noexcept {
static_assert(std::is_base_of_v<emitter<Derived>, Derived>, "Invalid emitter type");
}
@@ -106,7 +105,7 @@ public:
}
/*! @brief Disconnects all the listeners. */
void clear() ENTT_NOEXCEPT {
void clear() noexcept {
handlers.clear();
}
@@ -124,7 +123,7 @@ public:
* @brief Checks if there are listeners registered with the event emitter.
* @return True if there are no listeners registered, false otherwise.
*/
[[nodiscard]] bool empty() const ENTT_NOEXCEPT {
[[nodiscard]] bool empty() const noexcept {
return handlers.empty();
}

View File

@@ -6,7 +6,6 @@
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "delegate.hpp"
#include "fwd.hpp"
@@ -97,7 +96,7 @@ public:
* @brief Move constructor.
* @param other The instance to move from.
*/
sigh(sigh &&other) ENTT_NOEXCEPT
sigh(sigh &&other) noexcept
: calls{std::move(other.calls)} {}
/**
@@ -105,7 +104,7 @@ public:
* @param other The instance to move from.
* @param allocator The allocator to use.
*/
sigh(sigh &&other, const allocator_type &allocator) ENTT_NOEXCEPT
sigh(sigh &&other, const allocator_type &allocator) noexcept
: calls{std::move(other.calls), allocator} {}
/**
@@ -123,7 +122,7 @@ public:
* @param other The instance to move from.
* @return This signal handler.
*/
sigh &operator=(sigh &&other) ENTT_NOEXCEPT {
sigh &operator=(sigh &&other) noexcept {
calls = std::move(other.calls);
return *this;
}
@@ -141,7 +140,7 @@ public:
* @brief Returns the associated allocator.
* @return The associated allocator.
*/
[[nodiscard]] constexpr allocator_type get_allocator() const ENTT_NOEXCEPT {
[[nodiscard]] constexpr allocator_type get_allocator() const noexcept {
return calls.get_allocator();
}
@@ -156,7 +155,7 @@ public:
* @brief Number of listeners connected to the signal.
* @return Number of listeners currently connected.
*/
[[nodiscard]] size_type size() const ENTT_NOEXCEPT {
[[nodiscard]] size_type size() const noexcept {
return calls.size();
}
@@ -164,7 +163,7 @@ public:
* @brief Returns false if at least a listener is connected to the signal.
* @return True if the signal has no listeners connected, false otherwise.
*/
[[nodiscard]] bool empty() const ENTT_NOEXCEPT {
[[nodiscard]] bool empty() const noexcept {
return calls.empty();
}
@@ -245,7 +244,7 @@ public:
* @brief Checks whether a connection is properly initialized.
* @return True if the connection is properly initialized, false otherwise.
*/
[[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
[[nodiscard]] explicit operator bool() const noexcept {
return static_cast<bool>(disconnect);
}
@@ -289,7 +288,7 @@ struct scoped_connection {
* @brief Move constructor.
* @param other The scoped connection to move from.
*/
scoped_connection(scoped_connection &&other) ENTT_NOEXCEPT
scoped_connection(scoped_connection &&other) noexcept
: conn{std::exchange(other.conn, {})} {}
/*! @brief Automatically breaks the link on destruction. */
@@ -308,7 +307,7 @@ struct scoped_connection {
* @param other The scoped connection to move from.
* @return This scoped connection.
*/
scoped_connection &operator=(scoped_connection &&other) ENTT_NOEXCEPT {
scoped_connection &operator=(scoped_connection &&other) noexcept {
conn = std::exchange(other.conn, {});
return *this;
}
@@ -327,7 +326,7 @@ struct scoped_connection {
* @brief Checks whether a scoped connection is properly initialized.
* @return True if the connection is properly initialized, false otherwise.
*/
[[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
[[nodiscard]] explicit operator bool() const noexcept {
return static_cast<bool>(conn);
}
@@ -379,7 +378,7 @@ public:
* @brief Constructs a sink that is allowed to modify a given signal.
* @param ref A valid reference to a signal object.
*/
sink(sigh<Ret(Args...), Allocator> &ref) ENTT_NOEXCEPT
sink(sigh<Ret(Args...), Allocator> &ref) noexcept
: offset{},
signal{&ref} {}
@@ -387,7 +386,7 @@ public:
* @brief Returns false if at least a listener is connected to the sink.
* @return True if the sink has no listeners connected, false otherwise.
*/
[[nodiscard]] bool empty() const ENTT_NOEXCEPT {
[[nodiscard]] bool empty() const noexcept {
return signal->calls.empty();
}