diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 2618fe278..c2835de8d 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -21,14 +21,11 @@ namespace entt { * @tparam Len Size of the storage reserved for the small buffer optimization. * @tparam Align Optional alignment requirement. */ -template +template class basic_any { - static_assert(sizeof...(Align) == 0u || Len); - enum class operation { COPY, MOVE, DTOR, COMP, ADDR, CADDR, REF, CREF, TYPE }; - // cannot use std::aligned_storage_t with parameter packs because of an issue of msvc - using storage_type = typename std::aligned_storage::type; + using storage_type = std::aligned_storage_t; using vtable_type = const void *(const operation, const basic_any &, const void *); template @@ -341,13 +338,13 @@ private: /** * @brief Checks if two wrappers differ in their content. * @tparam Len Size of the storage reserved for the small buffer optimization. - * @tparam Align Optional alignment requirement. + * @tparam Align Alignment requirement. * @param lhs A wrapper, either empty or not. * @param rhs A wrapper, either empty or not. * @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 { +template +[[nodiscard]] inline bool operator!=(const basic_any &lhs, const basic_any &rhs) ENTT_NOEXCEPT { return !(lhs == rhs); } @@ -356,12 +353,12 @@ template * @brief Performs type-safe access to the contained object. * @tparam Type Type to which conversion is required. * @tparam Len Size of the storage reserved for the small buffer optimization. - * @tparam Align Optional alignment requirement. + * @tparam Align Alignment requirement. * @param data Target any object. * @return The element converted to the requested type. */ -template -Type any_cast(const basic_any &data) ENTT_NOEXCEPT { +template +Type any_cast(const basic_any &data) ENTT_NOEXCEPT { const auto * const instance = any_cast>(&data); ENTT_ASSERT(instance); return static_cast(*instance); @@ -369,8 +366,8 @@ Type any_cast(const basic_any &data) ENTT_NOEXCEPT { /*! @copydoc any_cast */ -template -Type any_cast(basic_any &data) ENTT_NOEXCEPT { +template +Type any_cast(basic_any &data) ENTT_NOEXCEPT { // forces const on non-reference types to make them work also with wrappers for const references auto * const instance = any_cast, std::remove_reference_t, const Type>>(&data); ENTT_ASSERT(instance); @@ -379,8 +376,8 @@ Type any_cast(basic_any &data) ENTT_NOEXCEPT { /*! @copydoc any_cast */ -template -Type any_cast(basic_any &&data) ENTT_NOEXCEPT { +template +Type any_cast(basic_any &&data) ENTT_NOEXCEPT { // forces const on non-reference types to make them work also with wrappers for const references auto * const instance = any_cast, std::remove_reference_t, const Type>>(&data); ENTT_ASSERT(instance); @@ -389,17 +386,17 @@ Type any_cast(basic_any &&data) ENTT_NOEXCEPT { /*! @copydoc any_cast */ -template -const Type * any_cast(const basic_any *data) ENTT_NOEXCEPT { +template +const Type * any_cast(const basic_any *data) ENTT_NOEXCEPT { return (data->type() == type_id() ? static_cast(data->data()) : nullptr); } /*! @copydoc any_cast */ -template -Type * any_cast(basic_any *data) ENTT_NOEXCEPT { +template +Type * any_cast(basic_any *data) ENTT_NOEXCEPT { // last attempt to make wrappers for const references return their values - return (data->type() == type_id() ? static_cast(static_cast, Type> *>(data)->data()) : nullptr); + return (data->type() == type_id() ? static_cast(static_cast, Type> *>(data)->data()) : nullptr); } diff --git a/src/entt/core/fwd.hpp b/src/entt/core/fwd.hpp index afbf4240a..da297ea19 100644 --- a/src/entt/core/fwd.hpp +++ b/src/entt/core/fwd.hpp @@ -2,13 +2,14 @@ #define ENTT_CORE_FWD_HPP +#include #include "../config/config.h" namespace entt { -template +template)> class basic_any; diff --git a/src/entt/poly/fwd.hpp b/src/entt/poly/fwd.hpp index b6cd5e495..32023e27d 100644 --- a/src/entt/poly/fwd.hpp +++ b/src/entt/poly/fwd.hpp @@ -2,10 +2,13 @@ #define ENTT_POLY_FWD_HPP +#include + + namespace entt { -template +template)> class basic_poly; diff --git a/src/entt/poly/poly.hpp b/src/entt/poly/poly.hpp index 241279468..6b191308a 100644 --- a/src/entt/poly/poly.hpp +++ b/src/entt/poly/poly.hpp @@ -46,26 +46,26 @@ struct poly_inspector { * @brief Static virtual table factory. * @tparam Concept Concept descriptor. * @tparam Len Size of the storage reserved for the small buffer optimization. - * @tparam Align Optional alignment requirement. + * @tparam Align Alignment requirement. */ -template +template class poly_vtable { using inspector = typename Concept::template type; template - static auto vtable_entry(Ret(*)(inspector &, Args...)) -> Ret(*)(basic_any &, Args...); + static auto vtable_entry(Ret(*)(inspector &, Args...)) -> Ret(*)(basic_any &, Args...); template - static auto vtable_entry(Ret(*)(const inspector &, Args...)) -> Ret(*)(const basic_any &, Args...); + static auto vtable_entry(Ret(*)(const inspector &, Args...)) -> Ret(*)(const basic_any &, Args...); template - static auto vtable_entry(Ret(*)(Args...)) -> Ret(*)(const basic_any &, Args...); + static auto vtable_entry(Ret(*)(Args...)) -> Ret(*)(const basic_any &, Args...); template - static auto vtable_entry(Ret(inspector:: *)(Args...)) -> Ret(*)(basic_any &, Args...); + static auto vtable_entry(Ret(inspector:: *)(Args...)) -> Ret(*)(basic_any &, Args...); template - static auto vtable_entry(Ret(inspector:: *)(Args...) const) -> Ret(*)(const basic_any &, Args...); + static auto vtable_entry(Ret(inspector:: *)(Args...) const) -> Ret(*)(const basic_any &, Args...); template static auto make_vtable(value_list) @@ -177,12 +177,12 @@ decltype(auto) poly_call(Poly &&self, Args &&... args) { * @tparam Len Size of the storage reserved for the small buffer optimization. * @tparam Align Optional alignment requirement. */ -template -class basic_poly: private Concept::template type>> { +template +class basic_poly: private Concept::template type>> { /*! @brief A poly base is allowed to snoop into a poly object. */ friend struct poly_base; - using vtable_type = typename poly_vtable::type; + using vtable_type = typename poly_vtable::type; public: /*! @brief Concept type. */ @@ -203,7 +203,7 @@ public: template explicit basic_poly(std::in_place_type_t, Args &&... args) : storage{std::in_place_type, std::forward(args)...}, - vtable{poly_vtable::template instance>>()} + vtable{poly_vtable::template instance>>()} {} /** @@ -340,7 +340,7 @@ public: } private: - basic_any storage; + basic_any storage; const vtable_type *vtable; };