meta: added meta_type::is_dereferenceable
This commit is contained in:
@@ -116,6 +116,7 @@ struct meta_type_node {
|
||||
const bool is_function_pointer;
|
||||
const bool is_member_object_pointer;
|
||||
const bool is_member_function_pointer;
|
||||
const bool is_dereferenceable;
|
||||
const bool is_sequence_container;
|
||||
const bool is_associative_container;
|
||||
const size_type rank;
|
||||
@@ -259,6 +260,7 @@ public:
|
||||
std::is_pointer_v<Type> && std::is_function_v<std::remove_pointer_t<Type>>,
|
||||
std::is_member_object_pointer_v<Type>,
|
||||
std::is_member_function_pointer_v<Type>,
|
||||
is_dereferenceable_v<Type>,
|
||||
is_sequence_container_v<Type>,
|
||||
is_associative_container_v<Type>,
|
||||
std::rank_v<Type>,
|
||||
|
||||
@@ -1415,6 +1415,14 @@ public:
|
||||
return node->is_member_function_pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether a type is dereferenceable or not.
|
||||
* @return True if the underlying type is dereferenceable, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_dereferenceable() const ENTT_NOEXCEPT {
|
||||
return node->is_dereferenceable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether a type refers to a sequence container or not.
|
||||
* @return True if the underlying type is a sequence container, false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/core/hashed_string.hpp>
|
||||
#include <entt/meta/factory.hpp>
|
||||
@@ -162,6 +163,10 @@ TEST_F(MetaType, Traits) {
|
||||
ASSERT_TRUE(entt::resolve<decltype(&clazz_t::member)>().is_member_function_pointer());
|
||||
ASSERT_FALSE(entt::resolve<decltype(&clazz_t::value)>().is_member_function_pointer());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<int *>().is_dereferenceable());
|
||||
ASSERT_TRUE(entt::resolve<std::shared_ptr<int>>().is_dereferenceable());
|
||||
ASSERT_FALSE(entt::resolve<int>().is_dereferenceable());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<std::vector<int>>().is_sequence_container());
|
||||
ASSERT_FALSE((entt::resolve<std::map<int, char>>().is_sequence_container()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user