* removed meta_type::is_integral (no alternative provided)
* removed meta_type::is_floating_point (no alternative provided)
* added meta_type::is_arithmetic, prepare for auto-generated implicit conversions
This commit is contained in:
Michele Caini
2021-08-07 20:43:02 +02:00
parent adec4f08c6
commit 6282195b80
4 changed files with 19 additions and 30 deletions

1
TODO
View File

@@ -5,6 +5,7 @@
* custom pools example (multi instance, tables, enable/disable, and so on...)
WIP:
* runtime components (registry), runtime events (dispatcher/emitter), ...
* add constrained type policy to iterable view
* add constrained type policy to view iterators
* custom allocators all over

View File

@@ -1099,20 +1099,12 @@ public:
}
/**
* @brief Checks whether a type refers to an integral type or not.
* @return True if the underlying type is an integral type, false otherwise.
*/
[[nodiscard]] bool is_integral() const ENTT_NOEXCEPT {
return !!(node->traits & internal::meta_traits::IS_INTEGRAL);
}
/**
* @brief Checks whether a type refers to a floating-point type or not.
* @return True if the underlying type is a floating-point type, false
* @brief Checks whether a type refers to an arithmetic type or not.
* @return True if the underlying type is an arithmetic type, false
* otherwise.
*/
[[nodiscard]] bool is_floating_point() const ENTT_NOEXCEPT {
return !!(node->traits & internal::meta_traits::IS_FLOATING_POINT);
[[nodiscard]] bool is_arithmetic() const ENTT_NOEXCEPT {
return !!(node->traits & internal::meta_traits::IS_ARITHMETIC);
}
/**

View File

@@ -35,17 +35,16 @@ enum class meta_traits: std::uint32_t {
IS_NONE = 0x0000,
IS_CONST = 0x0001,
IS_STATIC = 0x0002,
IS_INTEGRAL = 0x0004,
IS_FLOATING_POINT = 0x0008,
IS_ARRAY = 0x0010,
IS_ENUM = 0x0020,
IS_CLASS = 0x0080,
IS_POINTER = 0x0100,
IS_MEMBER_OBJECT_POINTER = 0x0200,
IS_MEMBER_FUNCTION_POINTER = 0x0400,
IS_META_POINTER_LIKE = 0x0800,
IS_META_SEQUENCE_CONTAINER = 0x1000,
IS_META_ASSOCIATIVE_CONTAINER = 0x2000,
IS_ARITHMETIC = 0x0004,
IS_ARRAY = 0x0008,
IS_ENUM = 0x0010,
IS_CLASS = 0x0020,
IS_POINTER = 0x0040,
IS_MEMBER_OBJECT_POINTER = 0x0080,
IS_MEMBER_FUNCTION_POINTER = 0x0100,
IS_META_POINTER_LIKE = 0x0200,
IS_META_SEQUENCE_CONTAINER = 0x0400,
IS_META_ASSOCIATIVE_CONTAINER = 0x0800,
_entt_enum_as_bitmask
};
@@ -184,8 +183,7 @@ public:
nullptr,
size_of_v<Type>,
internal::meta_traits::IS_NONE
| (std::is_integral_v<Type> ? internal::meta_traits::IS_INTEGRAL : internal::meta_traits::IS_NONE)
| (std::is_floating_point_v<Type> ? internal::meta_traits::IS_FLOATING_POINT : internal::meta_traits::IS_NONE)
| (std::is_arithmetic_v<Type> ? internal::meta_traits::IS_ARITHMETIC : internal::meta_traits::IS_NONE)
| (std::is_array_v<Type> ? internal::meta_traits::IS_ARRAY : internal::meta_traits::IS_NONE)
| (std::is_enum_v<Type> ? internal::meta_traits::IS_ENUM : internal::meta_traits::IS_NONE)
| (std::is_class_v<Type> ? internal::meta_traits::IS_CLASS : internal::meta_traits::IS_NONE)

View File

@@ -211,11 +211,9 @@ TEST_F(MetaType, SizeOf) {
}
TEST_F(MetaType, Traits) {
ASSERT_TRUE(entt::resolve<bool>().is_integral());
ASSERT_FALSE(entt::resolve<double>().is_integral());
ASSERT_TRUE(entt::resolve<double>().is_floating_point());
ASSERT_FALSE(entt::resolve<int>().is_floating_point());
ASSERT_TRUE(entt::resolve<bool>().is_arithmetic());
ASSERT_TRUE(entt::resolve<double>().is_arithmetic());
ASSERT_FALSE(entt::resolve<clazz_t>().is_arithmetic());
ASSERT_TRUE(entt::resolve<int[5]>().is_array());
ASSERT_TRUE(entt::resolve<int[5][3]>().is_array());