From e59ff47f6f0de125a2c4d215656993af414dd6ed Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 6 May 2022 08:30:49 +0200 Subject: [PATCH] core: prepare to remove ENTT_NOEXCEPT[_IF] --- src/entt/core/any.hpp | 40 ++++++++++++------------- src/entt/core/compressed_pair.hpp | 21 +++++++------ src/entt/core/enum.hpp | 17 +++++------ src/entt/core/hashed_string.hpp | 48 ++++++++++++++--------------- src/entt/core/ident.hpp | 3 +- src/entt/core/iterator.hpp | 11 ++++--- src/entt/core/memory.hpp | 28 ++++++++--------- src/entt/core/monostate.hpp | 4 +-- src/entt/core/tuple.hpp | 9 +++--- src/entt/core/type_info.hpp | 50 +++++++++++++++---------------- src/entt/core/utility.hpp | 7 ++--- 11 files changed, 116 insertions(+), 122 deletions(-) diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 2102959b9..dff75eba7 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -144,7 +144,7 @@ class basic_any { } } - basic_any(const basic_any &other, const policy pol) ENTT_NOEXCEPT + basic_any(const basic_any &other, const policy pol) noexcept : instance{other.data()}, info{other.info}, vtable{other.vtable}, @@ -157,7 +157,7 @@ public: static constexpr auto alignment = Align; /*! @brief Default constructor. */ - constexpr basic_any() ENTT_NOEXCEPT + constexpr basic_any() noexcept : instance{}, info{&type_id()}, vtable{}, @@ -201,7 +201,7 @@ public: * @brief Move constructor. * @param other The instance to move from. */ - basic_any(basic_any &&other) ENTT_NOEXCEPT + basic_any(basic_any &&other) noexcept : instance{}, info{other.info}, vtable{other.vtable}, @@ -238,7 +238,7 @@ public: * @param other The instance to move from. * @return This any object. */ - basic_any &operator=(basic_any &&other) ENTT_NOEXCEPT { + basic_any &operator=(basic_any &&other) noexcept { reset(); if(other.vtable) { @@ -268,7 +268,7 @@ public: * @brief Returns the object type if any, `type_id()` otherwise. * @return The object type if any, `type_id()` otherwise. */ - [[nodiscard]] const type_info &type() const ENTT_NOEXCEPT { + [[nodiscard]] const type_info &type() const noexcept { return *info; } @@ -276,7 +276,7 @@ public: * @brief Returns an opaque pointer to the contained instance. * @return An opaque pointer the contained instance, if any. */ - [[nodiscard]] const void *data() const ENTT_NOEXCEPT { + [[nodiscard]] const void *data() const noexcept { return vtable ? vtable(operation::get, *this, nullptr) : nullptr; } @@ -285,7 +285,7 @@ public: * @param req Expected type. * @return An opaque pointer the contained instance, if any. */ - [[nodiscard]] const void *data(const type_info &req) const ENTT_NOEXCEPT { + [[nodiscard]] const void *data(const type_info &req) const noexcept { return *info == req ? data() : nullptr; } @@ -293,7 +293,7 @@ public: * @brief Returns an opaque pointer to the contained instance. * @return An opaque pointer the contained instance, if any. */ - [[nodiscard]] void *data() ENTT_NOEXCEPT { + [[nodiscard]] void *data() noexcept { return (!vtable || mode == policy::cref) ? nullptr : const_cast(vtable(operation::get, *this, nullptr)); } @@ -302,7 +302,7 @@ public: * @param req Expected type. * @return An opaque pointer the contained instance, if any. */ - [[nodiscard]] void *data(const type_info &req) ENTT_NOEXCEPT { + [[nodiscard]] void *data(const type_info &req) noexcept { return *info == req ? data() : nullptr; } @@ -359,7 +359,7 @@ public: * @brief Returns false if a wrapper is empty, true otherwise. * @return False if the wrapper is empty, true otherwise. */ - [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT { + [[nodiscard]] explicit operator bool() const noexcept { return vtable != nullptr; } @@ -368,7 +368,7 @@ public: * @param other Wrapper with which to compare. * @return False if the two objects differ in their content, true otherwise. */ - bool operator==(const basic_any &other) const ENTT_NOEXCEPT { + bool operator==(const basic_any &other) const noexcept { if(vtable && *info == *other.info) { return (vtable(operation::compare, *this, other.data()) != nullptr); } @@ -380,12 +380,12 @@ public: * @brief Aliasing constructor. * @return A wrapper that shares a reference to an unmanaged object. */ - [[nodiscard]] basic_any as_ref() ENTT_NOEXCEPT { + [[nodiscard]] basic_any as_ref() noexcept { return basic_any{*this, (mode == policy::cref ? policy::cref : policy::ref)}; } /*! @copydoc as_ref */ - [[nodiscard]] basic_any as_ref() const ENTT_NOEXCEPT { + [[nodiscard]] basic_any as_ref() const noexcept { return basic_any{*this, policy::cref}; } @@ -393,7 +393,7 @@ public: * @brief Returns true if a wrapper owns its object, false otherwise. * @return True if the wrapper owns its object, false otherwise. */ - [[nodiscard]] bool owner() const ENTT_NOEXCEPT { + [[nodiscard]] bool owner() const noexcept { return (mode == policy::owner); } @@ -416,7 +416,7 @@ private: * @return True if the two wrappers differ in their content, false otherwise. */ template -[[nodiscard]] inline bool operator!=(const basic_any &lhs, const basic_any &rhs) ENTT_NOEXCEPT { +[[nodiscard]] inline bool operator!=(const basic_any &lhs, const basic_any &rhs) noexcept { return !(lhs == rhs); } @@ -429,7 +429,7 @@ template * @return The element converted to the requested type. */ template -Type any_cast(const basic_any &data) ENTT_NOEXCEPT { +Type any_cast(const basic_any &data) noexcept { const auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); @@ -437,7 +437,7 @@ Type any_cast(const basic_any &data) ENTT_NOEXCEPT { /*! @copydoc any_cast */ template -Type any_cast(basic_any &data) ENTT_NOEXCEPT { +Type any_cast(basic_any &data) noexcept { // forces const on non-reference types to make them work also with wrappers for const references auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); @@ -446,7 +446,7 @@ Type any_cast(basic_any &data) ENTT_NOEXCEPT { /*! @copydoc any_cast */ template -Type any_cast(basic_any &&data) ENTT_NOEXCEPT { +Type any_cast(basic_any &&data) noexcept { if constexpr(std::is_copy_constructible_v>>) { if(auto *const instance = any_cast>(&data); instance) { return static_cast(std::move(*instance)); @@ -462,14 +462,14 @@ Type any_cast(basic_any &&data) ENTT_NOEXCEPT { /*! @copydoc any_cast */ template -const Type *any_cast(const basic_any *data) ENTT_NOEXCEPT { +const Type *any_cast(const basic_any *data) noexcept { const auto &info = type_id>>(); return static_cast(data->data(info)); } /*! @copydoc any_cast */ template -Type *any_cast(basic_any *data) ENTT_NOEXCEPT { +Type *any_cast(basic_any *data) noexcept { const auto &info = type_id>>(); // last attempt to make wrappers for const references return their values return static_cast(static_cast, Type> *>(data)->data(info)); diff --git a/src/entt/core/compressed_pair.hpp b/src/entt/core/compressed_pair.hpp index 143973222..d335b8b0f 100644 --- a/src/entt/core/compressed_pair.hpp +++ b/src/entt/core/compressed_pair.hpp @@ -5,7 +5,6 @@ #include #include #include -#include "../config/config.h" #include "type_traits.hpp" namespace entt { @@ -34,11 +33,11 @@ struct compressed_pair_element { constexpr compressed_pair_element(std::tuple args, std::index_sequence) : value{std::forward(std::get(args))...} {} - [[nodiscard]] constexpr reference get() ENTT_NOEXCEPT { + [[nodiscard]] constexpr reference get() noexcept { return value; } - [[nodiscard]] constexpr const_reference get() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr const_reference get() const noexcept { return value; } @@ -64,11 +63,11 @@ struct compressed_pair_element args, std::index_sequence) : base_type{std::forward(std::get(args))...} {} - [[nodiscard]] constexpr reference get() ENTT_NOEXCEPT { + [[nodiscard]] constexpr reference get() noexcept { return *this; } - [[nodiscard]] constexpr const_reference get() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr const_reference get() const noexcept { return *this; } }; @@ -169,12 +168,12 @@ public: * @brief Returns the first element that a pair stores. * @return The first element that a pair stores. */ - [[nodiscard]] constexpr first_type &first() ENTT_NOEXCEPT { + [[nodiscard]] constexpr first_type &first() noexcept { return static_cast(*this).get(); } /*! @copydoc first */ - [[nodiscard]] constexpr const first_type &first() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr const first_type &first() const noexcept { return static_cast(*this).get(); } @@ -182,12 +181,12 @@ public: * @brief Returns the second element that a pair stores. * @return The second element that a pair stores. */ - [[nodiscard]] constexpr second_type &second() ENTT_NOEXCEPT { + [[nodiscard]] constexpr second_type &second() noexcept { return static_cast(*this).get(); } /*! @copydoc second */ - [[nodiscard]] constexpr const second_type &second() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr const second_type &second() const noexcept { return static_cast(*this).get(); } @@ -208,7 +207,7 @@ public: * reference to the second element if `Index` is 1. */ template - constexpr decltype(auto) get() ENTT_NOEXCEPT { + constexpr decltype(auto) get() noexcept { if constexpr(Index == 0u) { return first(); } else { @@ -219,7 +218,7 @@ public: /*! @copydoc get */ template - constexpr decltype(auto) get() const ENTT_NOEXCEPT { + constexpr decltype(auto) get() const noexcept { if constexpr(Index == 0u) { return first(); } else { diff --git a/src/entt/core/enum.hpp b/src/entt/core/enum.hpp index 8b19f7fed..5922c2f8e 100644 --- a/src/entt/core/enum.hpp +++ b/src/entt/core/enum.hpp @@ -2,7 +2,6 @@ #define ENTT_CORE_ENUM_HPP #include -#include "../config/config.h" namespace entt { @@ -36,21 +35,21 @@ inline constexpr bool enum_as_bitmask_v = enum_as_bitmask::value; */ template [[nodiscard]] constexpr std::enable_if_t, Type> -operator|(const Type lhs, const Type rhs) ENTT_NOEXCEPT { +operator|(const Type lhs, const Type rhs) noexcept { return static_cast(static_cast>(lhs) | static_cast>(rhs)); } /*! @copydoc operator| */ template [[nodiscard]] constexpr std::enable_if_t, Type> -operator&(const Type lhs, const Type rhs) ENTT_NOEXCEPT { +operator&(const Type lhs, const Type rhs) noexcept { return static_cast(static_cast>(lhs) & static_cast>(rhs)); } /*! @copydoc operator| */ template [[nodiscard]] constexpr std::enable_if_t, Type> -operator^(const Type lhs, const Type rhs) ENTT_NOEXCEPT { +operator^(const Type lhs, const Type rhs) noexcept { return static_cast(static_cast>(lhs) ^ static_cast>(rhs)); } @@ -63,35 +62,35 @@ operator^(const Type lhs, const Type rhs) ENTT_NOEXCEPT { */ template [[nodiscard]] constexpr std::enable_if_t, Type> -operator~(const Type value) ENTT_NOEXCEPT { +operator~(const Type value) noexcept { return static_cast(~static_cast>(value)); } /*! @copydoc operator~ */ template [[nodiscard]] constexpr std::enable_if_t, bool> -operator!(const Type value) ENTT_NOEXCEPT { +operator!(const Type value) noexcept { return !static_cast>(value); } /*! @copydoc operator| */ template constexpr std::enable_if_t, Type &> -operator|=(Type &lhs, const Type rhs) ENTT_NOEXCEPT { +operator|=(Type &lhs, const Type rhs) noexcept { return (lhs = (lhs | rhs)); } /*! @copydoc operator| */ template constexpr std::enable_if_t, Type &> -operator&=(Type &lhs, const Type rhs) ENTT_NOEXCEPT { +operator&=(Type &lhs, const Type rhs) noexcept { return (lhs = (lhs & rhs)); } /*! @copydoc operator| */ template constexpr std::enable_if_t, Type &> -operator^=(Type &lhs, const Type rhs) ENTT_NOEXCEPT { +operator^=(Type &lhs, const Type rhs) noexcept { return (lhs = (lhs ^ rhs)); } diff --git a/src/entt/core/hashed_string.hpp b/src/entt/core/hashed_string.hpp index f18de6677..3b6532a37 100644 --- a/src/entt/core/hashed_string.hpp +++ b/src/entt/core/hashed_string.hpp @@ -3,7 +3,6 @@ #include #include -#include "../config/config.h" #include "fwd.hpp" namespace entt { @@ -72,12 +71,13 @@ class basic_hashed_string: internal::basic_hashed_string { struct const_wrapper { // non-explicit constructor on purpose - constexpr const_wrapper(const Char *str) ENTT_NOEXCEPT: repr{str} {} + constexpr const_wrapper(const Char *str) noexcept + : repr{str} {} const Char *repr; }; // Fowler–Noll–Vo hash function v. 1a - the good - [[nodiscard]] static constexpr auto helper(const Char *str) ENTT_NOEXCEPT { + [[nodiscard]] static constexpr auto helper(const Char *str) noexcept { base_type base{str, 0u, hs_traits::offset}; for(; str[base.length]; ++base.length) { @@ -88,7 +88,7 @@ class basic_hashed_string: internal::basic_hashed_string { } // Fowler–Noll–Vo hash function v. 1a - the good - [[nodiscard]] static constexpr auto helper(const Char *str, const std::size_t len) ENTT_NOEXCEPT { + [[nodiscard]] static constexpr auto helper(const Char *str, const std::size_t len) noexcept { base_type base{str, len, hs_traits::offset}; for(size_type pos{}; pos < len; ++pos) { @@ -112,7 +112,7 @@ public: * @param len Length of the string to hash. * @return The numeric representation of the string. */ - [[nodiscard]] static constexpr hash_type value(const value_type *str, const size_type len) ENTT_NOEXCEPT { + [[nodiscard]] static constexpr hash_type value(const value_type *str, const size_type len) noexcept { return basic_hashed_string{str, len}; } @@ -123,7 +123,7 @@ public: * @return The numeric representation of the string. */ template - [[nodiscard]] static constexpr hash_type value(const value_type (&str)[N]) ENTT_NOEXCEPT { + [[nodiscard]] static constexpr hash_type value(const value_type (&str)[N]) noexcept { return basic_hashed_string{str}; } @@ -132,12 +132,12 @@ public: * @param wrapper Helps achieving the purpose by relying on overloading. * @return The numeric representation of the string. */ - [[nodiscard]] static constexpr hash_type value(const_wrapper wrapper) ENTT_NOEXCEPT { + [[nodiscard]] static constexpr hash_type value(const_wrapper wrapper) noexcept { return basic_hashed_string{wrapper}; } /*! @brief Constructs an empty hashed string. */ - constexpr basic_hashed_string() ENTT_NOEXCEPT + constexpr basic_hashed_string() noexcept : base_type{} {} /** @@ -145,7 +145,7 @@ public: * @param str Human-readable identifier. * @param len Length of the string to hash. */ - constexpr basic_hashed_string(const value_type *str, const size_type len) ENTT_NOEXCEPT + constexpr basic_hashed_string(const value_type *str, const size_type len) noexcept : base_type{helper(str, len)} {} /** @@ -154,7 +154,7 @@ public: * @param str Human-readable identifier. */ template - constexpr basic_hashed_string(const value_type (&str)[N]) ENTT_NOEXCEPT + constexpr basic_hashed_string(const value_type (&str)[N]) noexcept : base_type{helper(str)} {} /** @@ -166,14 +166,14 @@ public: * * @param wrapper Helps achieving the purpose by relying on overloading. */ - explicit constexpr basic_hashed_string(const_wrapper wrapper) ENTT_NOEXCEPT + explicit constexpr basic_hashed_string(const_wrapper wrapper) noexcept : base_type{helper(wrapper.repr)} {} /** * @brief Returns the size a hashed string. * @return The size of the hashed string. */ - [[nodiscard]] constexpr size_type size() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr size_type size() const noexcept { return base_type::length; } @@ -181,7 +181,7 @@ public: * @brief Returns the human-readable representation of a hashed string. * @return The string used to initialize the hashed string. */ - [[nodiscard]] constexpr const value_type *data() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr const value_type *data() const noexcept { return base_type::repr; } @@ -189,12 +189,12 @@ public: * @brief Returns the numeric representation of a hashed string. * @return The numeric representation of the hashed string. */ - [[nodiscard]] constexpr hash_type value() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr hash_type value() const noexcept { return base_type::hash; } /*! @copydoc data */ - [[nodiscard]] constexpr operator const value_type *() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr operator const value_type *() const noexcept { return data(); } @@ -202,7 +202,7 @@ public: * @brief Returns the numeric representation of a hashed string. * @return The numeric representation of the hashed string. */ - [[nodiscard]] constexpr operator hash_type() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr operator hash_type() const noexcept { return value(); } }; @@ -233,7 +233,7 @@ basic_hashed_string(const Char (&str)[N]) -> basic_hashed_string; * @return True if the two hashed strings are identical, false otherwise. */ template -[[nodiscard]] constexpr bool operator==(const basic_hashed_string &lhs, const basic_hashed_string &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator==(const basic_hashed_string &lhs, const basic_hashed_string &rhs) noexcept { return lhs.value() == rhs.value(); } @@ -245,7 +245,7 @@ template * @return True if the two hashed strings differ, false otherwise. */ template -[[nodiscard]] constexpr bool operator!=(const basic_hashed_string &lhs, const basic_hashed_string &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator!=(const basic_hashed_string &lhs, const basic_hashed_string &rhs) noexcept { return !(lhs == rhs); } @@ -257,7 +257,7 @@ template * @return True if the first element is less than the second, false otherwise. */ template -[[nodiscard]] constexpr bool operator<(const basic_hashed_string &lhs, const basic_hashed_string &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator<(const basic_hashed_string &lhs, const basic_hashed_string &rhs) noexcept { return lhs.value() < rhs.value(); } @@ -270,7 +270,7 @@ template * otherwise. */ template -[[nodiscard]] constexpr bool operator<=(const basic_hashed_string &lhs, const basic_hashed_string &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator<=(const basic_hashed_string &lhs, const basic_hashed_string &rhs) noexcept { return !(rhs < lhs); } @@ -283,7 +283,7 @@ template * otherwise. */ template -[[nodiscard]] constexpr bool operator>(const basic_hashed_string &lhs, const basic_hashed_string &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator>(const basic_hashed_string &lhs, const basic_hashed_string &rhs) noexcept { return rhs < lhs; } @@ -296,7 +296,7 @@ template * false otherwise. */ template -[[nodiscard]] constexpr bool operator>=(const basic_hashed_string &lhs, const basic_hashed_string &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator>=(const basic_hashed_string &lhs, const basic_hashed_string &rhs) noexcept { return !(lhs < rhs); } @@ -313,7 +313,7 @@ inline namespace literals { * @param str The literal without its suffix. * @return A properly initialized hashed string. */ -[[nodiscard]] constexpr hashed_string operator"" _hs(const char *str, std::size_t) ENTT_NOEXCEPT { +[[nodiscard]] constexpr hashed_string operator"" _hs(const char *str, std::size_t) noexcept { return hashed_string{str}; } @@ -322,7 +322,7 @@ inline namespace literals { * @param str The literal without its suffix. * @return A properly initialized hashed wstring. */ -[[nodiscard]] constexpr hashed_wstring operator"" _hws(const wchar_t *str, std::size_t) ENTT_NOEXCEPT { +[[nodiscard]] constexpr hashed_wstring operator"" _hws(const wchar_t *str, std::size_t) noexcept { return hashed_wstring{str}; } diff --git a/src/entt/core/ident.hpp b/src/entt/core/ident.hpp index db3a02e46..2ff602670 100644 --- a/src/entt/core/ident.hpp +++ b/src/entt/core/ident.hpp @@ -4,7 +4,6 @@ #include #include #include -#include "../config/config.h" #include "fwd.hpp" #include "type_traits.hpp" @@ -17,7 +16,7 @@ namespace entt { template class ident { template - [[nodiscard]] static constexpr id_type get(std::index_sequence) ENTT_NOEXCEPT { + [[nodiscard]] static constexpr id_type get(std::index_sequence) noexcept { static_assert((std::is_same_v || ...), "Invalid type"); return (0 + ... + (std::is_same_v...>>> ? id_type{Index} : id_type{})); } diff --git a/src/entt/core/iterator.hpp b/src/entt/core/iterator.hpp index 9222a69b1..f332a96d7 100644 --- a/src/entt/core/iterator.hpp +++ b/src/entt/core/iterator.hpp @@ -4,7 +4,6 @@ #include #include #include -#include "../config/config.h" namespace entt { @@ -46,7 +45,7 @@ struct input_iterator_pointer final { * @brief Access operator for accessing wrapped values. * @return A pointer to the wrapped value. */ - [[nodiscard]] constexpr pointer operator->() ENTT_NOEXCEPT { + [[nodiscard]] constexpr pointer operator->() noexcept { return std::addressof(value); } @@ -86,7 +85,7 @@ struct iterable_adaptor final { * @brief Returns an iterator to the beginning. * @return An iterator to the first element of the range. */ - [[nodiscard]] constexpr iterator begin() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr iterator begin() const noexcept { return first; } @@ -95,17 +94,17 @@ struct iterable_adaptor final { * @return An iterator to the element following the last element of the * range. */ - [[nodiscard]] constexpr sentinel end() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr sentinel end() const noexcept { return last; } /*! @copydoc begin */ - [[nodiscard]] constexpr iterator cbegin() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr iterator cbegin() const noexcept { return begin(); } /*! @copydoc end */ - [[nodiscard]] constexpr sentinel cend() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr sentinel cend() const noexcept { return end(); } diff --git a/src/entt/core/memory.hpp b/src/entt/core/memory.hpp index 26aab1913..25852e086 100644 --- a/src/entt/core/memory.hpp +++ b/src/entt/core/memory.hpp @@ -18,7 +18,7 @@ namespace entt { * @return A raw pointer that represents the address of the original pointer. */ template -[[nodiscard]] constexpr auto to_address(Type &&ptr) ENTT_NOEXCEPT { +[[nodiscard]] constexpr auto to_address(Type &&ptr) noexcept { if constexpr(std::is_pointer_v>>) { return ptr; } else { @@ -33,7 +33,7 @@ template * @param rhs Another valid allocator. */ template -constexpr void propagate_on_container_copy_assignment([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) ENTT_NOEXCEPT { +constexpr void propagate_on_container_copy_assignment([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept { if constexpr(std::allocator_traits::propagate_on_container_copy_assignment::value) { lhs = rhs; } @@ -46,7 +46,7 @@ constexpr void propagate_on_container_copy_assignment([[maybe_unused]] Allocator * @param rhs Another valid allocator. */ template -constexpr void propagate_on_container_move_assignment([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) ENTT_NOEXCEPT { +constexpr void propagate_on_container_move_assignment([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept { if constexpr(std::allocator_traits::propagate_on_container_move_assignment::value) { lhs = std::move(rhs); } @@ -59,7 +59,7 @@ constexpr void propagate_on_container_move_assignment([[maybe_unused]] Allocator * @param rhs Another valid allocator. */ template -constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) ENTT_NOEXCEPT { +constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept { ENTT_ASSERT(std::allocator_traits::propagate_on_container_swap::value || lhs == rhs, "Cannot swap the containers"); if constexpr(std::allocator_traits::propagate_on_container_swap::value) { @@ -73,7 +73,7 @@ constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[ma * @param value A value that may or may not be a power of two. * @return True if the value is a power of two, false otherwise. */ -[[nodiscard]] inline constexpr bool is_power_of_two(const std::size_t value) ENTT_NOEXCEPT { +[[nodiscard]] inline constexpr bool is_power_of_two(const std::size_t value) noexcept { return value && ((value & (value - 1)) == 0); } @@ -82,7 +82,7 @@ constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[ma * @param value The value to use. * @return The smallest power of two greater than or equal to the given value. */ -[[nodiscard]] inline constexpr std::size_t next_power_of_two(const std::size_t value) ENTT_NOEXCEPT { +[[nodiscard]] inline constexpr std::size_t next_power_of_two(const std::size_t value) noexcept { ENTT_ASSERT(value < (std::size_t{1u} << (std::numeric_limits::digits - 1)), "Numeric limits exceeded"); std::size_t curr = value - (value != 0u); @@ -99,7 +99,7 @@ constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[ma * @param mod _Modulus_, it must be a power of two. * @return The common remainder. */ -[[nodiscard]] inline constexpr std::size_t fast_mod(const std::size_t value, const std::size_t mod) ENTT_NOEXCEPT { +[[nodiscard]] inline constexpr std::size_t fast_mod(const std::size_t value, const std::size_t mod) noexcept { ENTT_ASSERT(is_power_of_two(mod), "Value must be a power of two"); return value & (mod - 1u); } @@ -173,7 +173,7 @@ namespace internal { template struct uses_allocator_construction { template - static constexpr auto args([[maybe_unused]] const Allocator &allocator, Params &&...params) ENTT_NOEXCEPT { + static constexpr auto args([[maybe_unused]] const Allocator &allocator, Params &&...params) noexcept { if constexpr(!std::uses_allocator_v && std::is_constructible_v) { return std::forward_as_tuple(std::forward(params)...); } else { @@ -194,7 +194,7 @@ struct uses_allocator_construction> { using type = std::pair; template - static constexpr auto args(const Allocator &allocator, std::piecewise_construct_t, First &&first, Second &&second) ENTT_NOEXCEPT { + static constexpr auto args(const Allocator &allocator, std::piecewise_construct_t, First &&first, Second &&second) noexcept { return std::make_tuple( std::piecewise_construct, std::apply([&allocator](auto &&...curr) { return uses_allocator_construction::args(allocator, std::forward(curr)...); }, std::forward(first)), @@ -202,22 +202,22 @@ struct uses_allocator_construction> { } template - static constexpr auto args(const Allocator &allocator) ENTT_NOEXCEPT { + static constexpr auto args(const Allocator &allocator) noexcept { return uses_allocator_construction::args(allocator, std::piecewise_construct, std::tuple<>{}, std::tuple<>{}); } template - static constexpr auto args(const Allocator &allocator, First &&first, Second &&second) ENTT_NOEXCEPT { + static constexpr auto args(const Allocator &allocator, First &&first, Second &&second) noexcept { return uses_allocator_construction::args(allocator, std::piecewise_construct, std::forward_as_tuple(std::forward(first)), std::forward_as_tuple(std::forward(second))); } template - static constexpr auto args(const Allocator &allocator, const std::pair &value) ENTT_NOEXCEPT { + static constexpr auto args(const Allocator &allocator, const std::pair &value) noexcept { return uses_allocator_construction::args(allocator, std::piecewise_construct, std::forward_as_tuple(value.first), std::forward_as_tuple(value.second)); } template - static constexpr auto args(const Allocator &allocator, std::pair &&value) ENTT_NOEXCEPT { + static constexpr auto args(const Allocator &allocator, std::pair &&value) noexcept { return uses_allocator_construction::args(allocator, std::piecewise_construct, std::forward_as_tuple(std::move(value.first)), std::forward_as_tuple(std::move(value.second))); } }; @@ -243,7 +243,7 @@ struct uses_allocator_construction> { * @return The arguments needed to create an object of the given type. */ template -constexpr auto uses_allocator_construction_args(const Allocator &allocator, Args &&...args) ENTT_NOEXCEPT { +constexpr auto uses_allocator_construction_args(const Allocator &allocator, Args &&...args) noexcept { return internal::uses_allocator_construction::args(allocator, std::forward(args)...); } diff --git a/src/entt/core/monostate.hpp b/src/entt/core/monostate.hpp index 1b08a0a6a..88225dbf0 100644 --- a/src/entt/core/monostate.hpp +++ b/src/entt/core/monostate.hpp @@ -25,7 +25,7 @@ struct monostate { * @param val User data to assign to the given key. */ template - void operator=(Type val) const ENTT_NOEXCEPT { + void operator=(Type val) const noexcept { value = val; } @@ -35,7 +35,7 @@ struct monostate { * @return Stored value, if any. */ template - operator Type() const ENTT_NOEXCEPT { + operator Type() const noexcept { return value; } diff --git a/src/entt/core/tuple.hpp b/src/entt/core/tuple.hpp index 168b9d1bf..ed52d6e11 100644 --- a/src/entt/core/tuple.hpp +++ b/src/entt/core/tuple.hpp @@ -4,7 +4,6 @@ #include #include #include -#include "../config/config.h" namespace entt { @@ -16,7 +15,7 @@ namespace entt { * element otherwise. */ template -constexpr decltype(auto) unwrap_tuple(Type &&value) ENTT_NOEXCEPT { +constexpr decltype(auto) unwrap_tuple(Type &&value) noexcept { if constexpr(std::tuple_size_v> == 1u) { return std::get<0>(std::forward(value)); } else { @@ -36,7 +35,7 @@ struct forward_apply: private Func { * @param args Parameters to use to construct the instance. */ template - constexpr forward_apply(Args &&...args) ENTT_NOEXCEPT_IF((std::is_nothrow_constructible_v)) + constexpr forward_apply(Args &&...args) noexcept(std::is_nothrow_constructible_v) : Func{std::forward(args)...} {} /** @@ -46,13 +45,13 @@ struct forward_apply: private Func { * @return Return value of the underlying function, if any. */ template - constexpr decltype(auto) operator()(Type &&args) ENTT_NOEXCEPT_IF(noexcept(std::apply(std::declval(), args))) { + constexpr decltype(auto) operator()(Type &&args) noexcept(noexcept(std::apply(std::declval(), args))) { return std::apply(static_cast(*this), std::forward(args)); } /*! @copydoc operator()() */ template - constexpr decltype(auto) operator()(Type &&args) const ENTT_NOEXCEPT_IF(noexcept(std::apply(std::declval(), args))) { + constexpr decltype(auto) operator()(Type &&args) const noexcept(noexcept(std::apply(std::declval(), args))) { return std::apply(static_cast(*this), std::forward(args)); } }; diff --git a/src/entt/core/type_info.hpp b/src/entt/core/type_info.hpp index bcae91126..bcf497777 100644 --- a/src/entt/core/type_info.hpp +++ b/src/entt/core/type_info.hpp @@ -19,14 +19,14 @@ namespace entt { namespace internal { struct ENTT_API type_index final { - [[nodiscard]] static id_type next() ENTT_NOEXCEPT { + [[nodiscard]] static id_type next() noexcept { static ENTT_MAYBE_ATOMIC(id_type) value{}; return value++; } }; template -[[nodiscard]] constexpr auto stripped_type_name() ENTT_NOEXCEPT { +[[nodiscard]] constexpr auto stripped_type_name() noexcept { #if defined ENTT_PRETTY_FUNCTION std::string_view pretty_function{ENTT_PRETTY_FUNCTION}; auto first = pretty_function.find_first_not_of(' ', pretty_function.find_first_of(ENTT_PRETTY_FUNCTION_PREFIX) + 1); @@ -38,26 +38,26 @@ template } template().find_first_of('.')> -[[nodiscard]] static constexpr std::string_view type_name(int) ENTT_NOEXCEPT { +[[nodiscard]] static constexpr std::string_view type_name(int) noexcept { constexpr auto value = stripped_type_name(); return value; } template -[[nodiscard]] static std::string_view type_name(char) ENTT_NOEXCEPT { +[[nodiscard]] static std::string_view type_name(char) noexcept { static const auto value = stripped_type_name(); return value; } template().find_first_of('.')> -[[nodiscard]] static constexpr id_type type_hash(int) ENTT_NOEXCEPT { +[[nodiscard]] static constexpr id_type type_hash(int) noexcept { constexpr auto stripped = stripped_type_name(); constexpr auto value = hashed_string::value(stripped.data(), stripped.size()); return value; } template -[[nodiscard]] static id_type type_hash(char) ENTT_NOEXCEPT { +[[nodiscard]] static id_type type_hash(char) noexcept { static const auto value = [](const auto stripped) { return hashed_string::value(stripped.data(), stripped.size()); }(stripped_type_name()); @@ -81,13 +81,13 @@ struct ENTT_API type_index final { * @brief Returns the sequential identifier of a given type. * @return The sequential identifier of a given type. */ - [[nodiscard]] static id_type value() ENTT_NOEXCEPT { + [[nodiscard]] static id_type value() noexcept { static const id_type value = internal::type_index::next(); return value; } /*! @copydoc value */ - [[nodiscard]] constexpr operator id_type() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr operator id_type() const noexcept { return value(); } }; @@ -103,16 +103,16 @@ struct type_hash final { * @return The numeric representation of the given type. */ #if defined ENTT_PRETTY_FUNCTION - [[nodiscard]] static constexpr id_type value() ENTT_NOEXCEPT { + [[nodiscard]] static constexpr id_type value() noexcept { return internal::type_hash(0); #else - [[nodiscard]] static constexpr id_type value() ENTT_NOEXCEPT { + [[nodiscard]] static constexpr id_type value() noexcept { return type_index::value(); #endif } /*! @copydoc value */ - [[nodiscard]] constexpr operator id_type() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr operator id_type() const noexcept { return value(); } }; @@ -127,12 +127,12 @@ struct type_name final { * @brief Returns the name of a given type. * @return The name of the given type. */ - [[nodiscard]] static constexpr std::string_view value() ENTT_NOEXCEPT { + [[nodiscard]] static constexpr std::string_view value() noexcept { return internal::type_name(0); } /*! @copydoc value */ - [[nodiscard]] constexpr operator std::string_view() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr operator std::string_view() const noexcept { return value(); } }; @@ -144,7 +144,7 @@ struct type_info final { * @tparam Type Type for which to construct a type info object. */ template - constexpr type_info(std::in_place_type_t) ENTT_NOEXCEPT + constexpr type_info(std::in_place_type_t) noexcept : seq{type_index>>::value()}, identifier{type_hash>>::value()}, alias{type_name>>::value()} {} @@ -153,7 +153,7 @@ struct type_info final { * @brief Type index. * @return Type index. */ - [[nodiscard]] constexpr id_type index() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr id_type index() const noexcept { return seq; } @@ -161,7 +161,7 @@ struct type_info final { * @brief Type hash. * @return Type hash. */ - [[nodiscard]] constexpr id_type hash() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr id_type hash() const noexcept { return identifier; } @@ -169,7 +169,7 @@ struct type_info final { * @brief Type name. * @return Type name. */ - [[nodiscard]] constexpr std::string_view name() const ENTT_NOEXCEPT { + [[nodiscard]] constexpr std::string_view name() const noexcept { return alias; } @@ -185,7 +185,7 @@ private: * @param rhs A type info object. * @return True if the two type info objects are identical, false otherwise. */ -[[nodiscard]] inline constexpr bool operator==(const type_info &lhs, const type_info &rhs) ENTT_NOEXCEPT { +[[nodiscard]] inline constexpr bool operator==(const type_info &lhs, const type_info &rhs) noexcept { return lhs.hash() == rhs.hash(); } @@ -195,7 +195,7 @@ private: * @param rhs A type info object. * @return True if the two type info objects differ, false otherwise. */ -[[nodiscard]] inline constexpr bool operator!=(const type_info &lhs, const type_info &rhs) ENTT_NOEXCEPT { +[[nodiscard]] inline constexpr bool operator!=(const type_info &lhs, const type_info &rhs) noexcept { return !(lhs == rhs); } @@ -205,7 +205,7 @@ private: * @param rhs A valid type info object. * @return True if the first element is less than the second, false otherwise. */ -[[nodiscard]] constexpr bool operator<(const type_info &lhs, const type_info &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator<(const type_info &lhs, const type_info &rhs) noexcept { return lhs.index() < rhs.index(); } @@ -216,7 +216,7 @@ private: * @return True if the first element is less than or equal to the second, false * otherwise. */ -[[nodiscard]] constexpr bool operator<=(const type_info &lhs, const type_info &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator<=(const type_info &lhs, const type_info &rhs) noexcept { return !(rhs < lhs); } @@ -227,7 +227,7 @@ private: * @return True if the first element is greater than the second, false * otherwise. */ -[[nodiscard]] constexpr bool operator>(const type_info &lhs, const type_info &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator>(const type_info &lhs, const type_info &rhs) noexcept { return rhs < lhs; } @@ -238,7 +238,7 @@ private: * @return True if the first element is greater than or equal to the second, * false otherwise. */ -[[nodiscard]] constexpr bool operator>=(const type_info &lhs, const type_info &rhs) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator>=(const type_info &lhs, const type_info &rhs) noexcept { return !(lhs < rhs); } @@ -254,7 +254,7 @@ private: * @return A reference to a properly initialized type info object. */ template -[[nodiscard]] const type_info &type_id() ENTT_NOEXCEPT { +[[nodiscard]] const type_info &type_id() noexcept { if constexpr(std::is_same_v>>) { static type_info instance{std::in_place_type}; return instance; @@ -265,7 +265,7 @@ template /*! @copydoc type_id */ template -[[nodiscard]] const type_info &type_id(Type &&) ENTT_NOEXCEPT { +[[nodiscard]] const type_info &type_id(Type &&) noexcept { return type_id>>(); } diff --git a/src/entt/core/utility.hpp b/src/entt/core/utility.hpp index 7c4ea81ad..c938f81d9 100644 --- a/src/entt/core/utility.hpp +++ b/src/entt/core/utility.hpp @@ -2,7 +2,6 @@ #define ENTT_CORE_UTILITY_HPP #include -#include "../config/config.h" namespace entt { @@ -18,7 +17,7 @@ struct identity { * @return The submitted value as-is. */ template - [[nodiscard]] constexpr Type &&operator()(Type &&value) const ENTT_NOEXCEPT { + [[nodiscard]] constexpr Type &&operator()(Type &&value) const noexcept { return std::forward(value); } }; @@ -31,7 +30,7 @@ struct identity { * @return Pointer to the member. */ template -[[nodiscard]] constexpr auto overload(Type Class::*member) ENTT_NOEXCEPT { +[[nodiscard]] constexpr auto overload(Type Class::*member) noexcept { return member; } @@ -42,7 +41,7 @@ template * @return Pointer to the function. */ template -[[nodiscard]] constexpr auto overload(Func *func) ENTT_NOEXCEPT { +[[nodiscard]] constexpr auto overload(Func *func) noexcept { return func; }