|
@@ -6,7 +6,6 @@
|
|
|
#include <tuple>
|
|
#include <tuple>
|
|
|
#include <type_traits>
|
|
#include <type_traits>
|
|
|
#include <utility>
|
|
#include <utility>
|
|
|
-#include "../config/config.h"
|
|
|
|
|
#include "../core/any.hpp"
|
|
#include "../core/any.hpp"
|
|
|
#include "../core/type_info.hpp"
|
|
#include "../core/type_info.hpp"
|
|
|
#include "../core/type_traits.hpp"
|
|
#include "../core/type_traits.hpp"
|
|
@@ -64,11 +63,11 @@ class poly_vtable {
|
|
|
static auto vtable_entry(Ret (inspector::*)(Args...) const) -> Ret (*)(const basic_any<Len, Align> &, Args...);
|
|
static auto vtable_entry(Ret (inspector::*)(Args...) const) -> Ret (*)(const basic_any<Len, Align> &, Args...);
|
|
|
|
|
|
|
|
template<auto... Candidate>
|
|
template<auto... Candidate>
|
|
|
- static auto make_vtable(value_list<Candidate...>) ENTT_NOEXCEPT
|
|
|
|
|
|
|
+ static auto make_vtable(value_list<Candidate...>) noexcept
|
|
|
-> decltype(std::make_tuple(vtable_entry(Candidate)...));
|
|
-> decltype(std::make_tuple(vtable_entry(Candidate)...));
|
|
|
|
|
|
|
|
template<typename... Func>
|
|
template<typename... Func>
|
|
|
- [[nodiscard]] static constexpr auto make_vtable(type_list<Func...>) ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] static constexpr auto make_vtable(type_list<Func...>) noexcept {
|
|
|
if constexpr(sizeof...(Func) == 0u) {
|
|
if constexpr(sizeof...(Func) == 0u) {
|
|
|
return decltype(make_vtable(typename Concept::template impl<inspector>{})){};
|
|
return decltype(make_vtable(typename Concept::template impl<inspector>{})){};
|
|
|
} else if constexpr((std::is_function_v<Func> && ...)) {
|
|
} else if constexpr((std::is_function_v<Func> && ...)) {
|
|
@@ -77,7 +76,7 @@ class poly_vtable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template<typename Type, auto Candidate, typename Ret, typename Any, typename... Args>
|
|
template<typename Type, auto Candidate, typename Ret, typename Any, typename... Args>
|
|
|
- static void fill_vtable_entry(Ret (*&entry)(Any &, Args...)) ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ static void fill_vtable_entry(Ret (*&entry)(Any &, Args...)) noexcept {
|
|
|
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
|
|
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
|
|
|
entry = +[](Any &, Args... args) -> Ret {
|
|
entry = +[](Any &, Args... args) -> Ret {
|
|
|
return std::invoke(Candidate, std::forward<Args>(args)...);
|
|
return std::invoke(Candidate, std::forward<Args>(args)...);
|
|
@@ -90,7 +89,7 @@ class poly_vtable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template<typename Type, auto... Index>
|
|
template<typename Type, auto... Index>
|
|
|
- [[nodiscard]] static auto fill_vtable(std::index_sequence<Index...>) ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] static auto fill_vtable(std::index_sequence<Index...>) noexcept {
|
|
|
vtable_type impl{};
|
|
vtable_type impl{};
|
|
|
(fill_vtable_entry<Type, value_list_element_v<Index, typename Concept::template impl<Type>>>(std::get<Index>(impl)), ...);
|
|
(fill_vtable_entry<Type, value_list_element_v<Index, typename Concept::template impl<Type>>>(std::get<Index>(impl)), ...);
|
|
|
return impl;
|
|
return impl;
|
|
@@ -109,7 +108,7 @@ public:
|
|
|
* @return A static virtual table for the given concept and type.
|
|
* @return A static virtual table for the given concept and type.
|
|
|
*/
|
|
*/
|
|
|
template<typename Type>
|
|
template<typename Type>
|
|
|
- [[nodiscard]] static type instance() ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] static type instance() noexcept {
|
|
|
static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Type differs from its decayed form");
|
|
static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Type differs from its decayed form");
|
|
|
static const vtable_type vtable = fill_vtable<Type>(std::make_index_sequence<Concept::template impl<Type>::size>{});
|
|
static const vtable_type vtable = fill_vtable<Type>(std::make_index_sequence<Concept::template impl<Type>::size>{});
|
|
|
|
|
|
|
@@ -201,7 +200,7 @@ public:
|
|
|
using vtable_type = typename poly_vtable<Concept, Len, Align>::type;
|
|
using vtable_type = typename poly_vtable<Concept, Len, Align>::type;
|
|
|
|
|
|
|
|
/*! @brief Default constructor. */
|
|
/*! @brief Default constructor. */
|
|
|
- basic_poly() ENTT_NOEXCEPT
|
|
|
|
|
|
|
+ basic_poly() noexcept
|
|
|
: storage{},
|
|
: storage{},
|
|
|
vtable{} {}
|
|
vtable{} {}
|
|
|
|
|
|
|
@@ -222,14 +221,14 @@ public:
|
|
|
* @param value An instance of an object to use to initialize the poly.
|
|
* @param value An instance of an object to use to initialize the poly.
|
|
|
*/
|
|
*/
|
|
|
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, basic_poly>>>
|
|
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, basic_poly>>>
|
|
|
- basic_poly(Type &&value) ENTT_NOEXCEPT
|
|
|
|
|
|
|
+ basic_poly(Type &&value) noexcept
|
|
|
: basic_poly{std::in_place_type<std::remove_cv_t<std::remove_reference_t<Type>>>, std::forward<Type>(value)} {}
|
|
: basic_poly{std::in_place_type<std::remove_cv_t<std::remove_reference_t<Type>>>, std::forward<Type>(value)} {}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @brief Returns the object type if any, `type_id<void>()` otherwise.
|
|
* @brief Returns the object type if any, `type_id<void>()` otherwise.
|
|
|
* @return The object type if any, `type_id<void>()` otherwise.
|
|
* @return The object type if any, `type_id<void>()` otherwise.
|
|
|
*/
|
|
*/
|
|
|
- [[nodiscard]] const type_info &type() const ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] const type_info &type() const noexcept {
|
|
|
return storage.type();
|
|
return storage.type();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -237,12 +236,12 @@ public:
|
|
|
* @brief Returns an opaque pointer to the contained instance.
|
|
* @brief Returns an opaque pointer to the contained instance.
|
|
|
* @return An opaque pointer the contained instance, if any.
|
|
* @return An opaque pointer the contained instance, if any.
|
|
|
*/
|
|
*/
|
|
|
- [[nodiscard]] const void *data() const ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] const void *data() const noexcept {
|
|
|
return storage.data();
|
|
return storage.data();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*! @copydoc data */
|
|
/*! @copydoc data */
|
|
|
- [[nodiscard]] void *data() ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] void *data() noexcept {
|
|
|
return storage.data();
|
|
return storage.data();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -268,7 +267,7 @@ public:
|
|
|
* @brief Returns false if a poly is empty, true otherwise.
|
|
* @brief Returns false if a poly is empty, true otherwise.
|
|
|
* @return False if the poly is empty, true otherwise.
|
|
* @return False if the poly is empty, true otherwise.
|
|
|
*/
|
|
*/
|
|
|
- [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] explicit operator bool() const noexcept {
|
|
|
return static_cast<bool>(storage);
|
|
return static_cast<bool>(storage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -276,12 +275,12 @@ public:
|
|
|
* @brief Returns a pointer to the underlying concept.
|
|
* @brief Returns a pointer to the underlying concept.
|
|
|
* @return A pointer to the underlying concept.
|
|
* @return A pointer to the underlying concept.
|
|
|
*/
|
|
*/
|
|
|
- [[nodiscard]] concept_type *operator->() ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] concept_type *operator->() noexcept {
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*! @copydoc operator-> */
|
|
/*! @copydoc operator-> */
|
|
|
- [[nodiscard]] const concept_type *operator->() const ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] const concept_type *operator->() const noexcept {
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -289,7 +288,7 @@ public:
|
|
|
* @brief Aliasing constructor.
|
|
* @brief Aliasing constructor.
|
|
|
* @return A poly that shares a reference to an unmanaged object.
|
|
* @return A poly that shares a reference to an unmanaged object.
|
|
|
*/
|
|
*/
|
|
|
- [[nodiscard]] basic_poly as_ref() ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] basic_poly as_ref() noexcept {
|
|
|
basic_poly ref{};
|
|
basic_poly ref{};
|
|
|
ref.storage = storage.as_ref();
|
|
ref.storage = storage.as_ref();
|
|
|
ref.vtable = vtable;
|
|
ref.vtable = vtable;
|
|
@@ -297,7 +296,7 @@ public:
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*! @copydoc as_ref */
|
|
/*! @copydoc as_ref */
|
|
|
- [[nodiscard]] basic_poly as_ref() const ENTT_NOEXCEPT {
|
|
|
|
|
|
|
+ [[nodiscard]] basic_poly as_ref() const noexcept {
|
|
|
basic_poly ref{};
|
|
basic_poly ref{};
|
|
|
ref.storage = storage.as_ref();
|
|
ref.storage = storage.as_ref();
|
|
|
ref.vtable = vtable;
|
|
ref.vtable = vtable;
|