|
@@ -5,6 +5,7 @@
|
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
#include <cstddef>
|
|
#include <cstddef>
|
|
|
#include <type_traits>
|
|
#include <type_traits>
|
|
|
|
|
+#include <utility>
|
|
|
#include "../core/attribute.h"
|
|
#include "../core/attribute.h"
|
|
|
#include "../config/config.h"
|
|
#include "../config/config.h"
|
|
|
#include "../core/fwd.hpp"
|
|
#include "../core/fwd.hpp"
|
|
@@ -114,7 +115,8 @@ struct meta_type_node {
|
|
|
const bool is_function_pointer;
|
|
const bool is_function_pointer;
|
|
|
const bool is_member_object_pointer;
|
|
const bool is_member_object_pointer;
|
|
|
const bool is_member_function_pointer;
|
|
const bool is_member_function_pointer;
|
|
|
- const size_type extent;
|
|
|
|
|
|
|
+ const size_type rank;
|
|
|
|
|
+ size_type(* const extent)(size_type);
|
|
|
bool(* const compare)(const void *, const void *);
|
|
bool(* const compare)(const void *, const void *);
|
|
|
meta_type_node *(* const remove_pointer)() ENTT_NOEXCEPT;
|
|
meta_type_node *(* const remove_pointer)() ENTT_NOEXCEPT;
|
|
|
meta_type_node *(* const remove_extent)() ENTT_NOEXCEPT;
|
|
meta_type_node *(* const remove_extent)() ENTT_NOEXCEPT;
|
|
@@ -212,10 +214,10 @@ auto find_if(const Op &op, const meta_type_node *node)
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Type>
|
|
template<typename Type>
|
|
|
-struct ENTT_API meta_node {
|
|
|
|
|
|
|
+class ENTT_API meta_node {
|
|
|
static_assert(std::is_same_v<Type, std::remove_cv_t<std::remove_reference_t<Type>>>, "Invalid type");
|
|
static_assert(std::is_same_v<Type, std::remove_cv_t<std::remove_reference_t<Type>>>, "Invalid type");
|
|
|
|
|
|
|
|
- [[nodiscard]] static bool compare(const void *lhs, const void *rhs) {
|
|
|
|
|
|
|
+ [[nodiscard]] static auto compare(const void *lhs, const void *rhs) {
|
|
|
if constexpr(!std::is_function_v<Type> && is_equality_comparable_v<Type>) {
|
|
if constexpr(!std::is_function_v<Type> && is_equality_comparable_v<Type>) {
|
|
|
return *static_cast<const Type *>(lhs) == *static_cast<const Type *>(rhs);
|
|
return *static_cast<const Type *>(lhs) == *static_cast<const Type *>(rhs);
|
|
|
} else {
|
|
} else {
|
|
@@ -223,6 +225,14 @@ struct ENTT_API meta_node {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ template<std::size_t... Index>
|
|
|
|
|
+ [[nodiscard]] static auto extent(meta_type_node::size_type dim, std::index_sequence<Index...>) {
|
|
|
|
|
+ meta_type_node::size_type ext{};
|
|
|
|
|
+ ((ext = (dim == Index ? std::extent_v<Type, Index> : ext)), ...);
|
|
|
|
|
+ return ext;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+public:
|
|
|
[[nodiscard]] static meta_type_node * resolve() ENTT_NOEXCEPT {
|
|
[[nodiscard]] static meta_type_node * resolve() ENTT_NOEXCEPT {
|
|
|
static meta_type_node node{
|
|
static meta_type_node node{
|
|
|
type_info<Type>::id(),
|
|
type_info<Type>::id(),
|
|
@@ -240,7 +250,10 @@ struct ENTT_API meta_node {
|
|
|
std::is_pointer_v<Type> && std::is_function_v<std::remove_pointer_t<Type>>,
|
|
std::is_pointer_v<Type> && std::is_function_v<std::remove_pointer_t<Type>>,
|
|
|
std::is_member_object_pointer_v<Type>,
|
|
std::is_member_object_pointer_v<Type>,
|
|
|
std::is_member_function_pointer_v<Type>,
|
|
std::is_member_function_pointer_v<Type>,
|
|
|
- std::extent_v<Type>,
|
|
|
|
|
|
|
+ std::rank_v<Type>,
|
|
|
|
|
+ [](meta_type_node::size_type dim) {
|
|
|
|
|
+ return extent(dim, std::make_index_sequence<std::rank_v<Type>>{});
|
|
|
|
|
+ },
|
|
|
&compare, // workaround for an issue with VS2017
|
|
&compare, // workaround for an issue with VS2017
|
|
|
&meta_node<std::remove_const_t<std::remove_pointer_t<Type>>>::resolve,
|
|
&meta_node<std::remove_const_t<std::remove_pointer_t<Type>>>::resolve,
|
|
|
&meta_node<std::remove_const_t<std::remove_extent_t<Type>>>::resolve
|
|
&meta_node<std::remove_const_t<std::remove_extent_t<Type>>>::resolve
|