Browse Source

signal: prepare to remove ENTT_NOEXCEPT[_IF]

Michele Caini 3 years ago
parent
commit
942879bbba
4 changed files with 42 additions and 45 deletions
  1. 15 15
      src/entt/signal/delegate.hpp
  2. 12 13
      src/entt/signal/dispatcher.hpp
  3. 3 4
      src/entt/signal/emitter.hpp
  4. 12 13
      src/entt/signal/sigh.hpp

+ 15 - 15
src/entt/signal/delegate.hpp

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

+ 12 - 13
src/entt/signal/dispatcher.hpp

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

+ 3 - 4
src/entt/signal/emitter.hpp

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

+ 12 - 13
src/entt/signal/sigh.hpp

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