meta: added meta_type::remove_extent (close #345)
This commit is contained in:
@@ -120,6 +120,7 @@ struct meta_type_node {
|
||||
const size_type extent;
|
||||
bool(* const compare)(const void *, const void *);
|
||||
meta_type_node *(* const remove_pointer)() ENTT_NOEXCEPT;
|
||||
meta_type_node *(* const remove_extent)() ENTT_NOEXCEPT;
|
||||
meta_base_node *base{nullptr};
|
||||
meta_conv_node *conv{nullptr};
|
||||
meta_ctor_node *ctor{nullptr};
|
||||
@@ -261,6 +262,9 @@ struct meta_node<Type> {
|
||||
&compare<Type>, // workaround for an issue with VS2017
|
||||
[]() ENTT_NOEXCEPT -> meta_type_node * {
|
||||
return meta_node<std::remove_const_t<std::remove_pointer_t<Type>>>::resolve();
|
||||
},
|
||||
[]() ENTT_NOEXCEPT -> meta_type_node * {
|
||||
return meta_node<std::remove_const_t<std::remove_extent_t<Type>>>::resolve();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1487,6 +1491,15 @@ public:
|
||||
return node->remove_pointer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Provides the meta type for which the array is defined.
|
||||
* @return The meta type for which the array is defined or this meta type
|
||||
* if it doesn't refer to an array type.
|
||||
*/
|
||||
meta_type remove_extent() const ENTT_NOEXCEPT {
|
||||
return node->remove_extent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all the meta base of a meta type.
|
||||
*
|
||||
|
||||
@@ -1732,6 +1732,12 @@ TEST_F(Meta, MetaTypeRemovePointer) {
|
||||
ASSERT_EQ(entt::resolve<derived_type>().remove_pointer(), entt::resolve<derived_type>());
|
||||
}
|
||||
|
||||
TEST_F(Meta, MetaTypeRemoveExtent) {
|
||||
ASSERT_EQ(entt::resolve<int[3]>().remove_extent(), entt::resolve<int>());
|
||||
ASSERT_EQ(entt::resolve<int[3][3]>().remove_extent(), entt::resolve<int[3]>());
|
||||
ASSERT_EQ(entt::resolve<derived_type>().remove_extent(), entt::resolve<derived_type>());
|
||||
}
|
||||
|
||||
TEST_F(Meta, MetaTypeBase) {
|
||||
auto type = entt::resolve<derived_type>();
|
||||
bool iterate = false;
|
||||
|
||||
Reference in New Issue
Block a user