stl: std::is_enum_v

This commit is contained in:
skypjack
2026-04-08 09:45:30 +02:00
parent 5d823e6853
commit 61a2aaa0c9
6 changed files with 10 additions and 9 deletions

View File

@@ -16,7 +16,7 @@ struct enum_as_bitmask: stl::false_type {};
/*! @copydoc enum_as_bitmask */
template<typename Type>
requires requires {
requires std::is_enum_v<Type>;
requires stl::is_enum_v<Type>;
{ Type::_entt_enum_as_bitmask } -> std::same_as<Type>;
}
struct enum_as_bitmask<Type>: stl::true_type {};
@@ -34,7 +34,7 @@ inline constexpr bool enum_as_bitmask_v = enum_as_bitmask<Type>::value;
*/
template<typename Type>
// check again that it is an enum to deal with incorrect specializations
concept enum_bitmask = std::is_enum_v<Type> && enum_as_bitmask_v<Type>;
concept enum_bitmask = stl::is_enum_v<Type> && enum_as_bitmask_v<Type>;
} // namespace entt

View File

@@ -20,7 +20,7 @@ struct entt_traits;
template<typename Type>
requires requires {
requires std::is_enum_v<Type>;
requires stl::is_enum_v<Type>;
typename internal::entt_traits<stl::underlying_type_t<Type>>::value_type;
}
struct entt_traits<Type>: entt_traits<stl::underlying_type_t<Type>> {

View File

@@ -520,7 +520,7 @@ public:
*/
template<typename Value>
meta_factory traits(const Value value, const bool unset = false) {
static_assert(std::is_enum_v<Value>, "Invalid enum type");
static_assert(stl::is_enum_v<Value>, "Invalid enum type");
base_type::traits(internal::user_to_meta_traits(value), unset);
return *this;
}

View File

@@ -498,7 +498,7 @@ public:
if(storage.has_value<stl::remove_cvref_t<Type>>()) {
return as_ref();
} else if(*this) {
if constexpr(std::is_arithmetic_v<stl::remove_cvref_t<Type>> || std::is_enum_v<stl::remove_cvref_t<Type>>) {
if constexpr(std::is_arithmetic_v<stl::remove_cvref_t<Type>> || stl::is_enum_v<stl::remove_cvref_t<Type>>) {
if(const auto &from = fetch_node(); from.conversion_helper) {
return meta_any{*ctx, static_cast<Type>(from.conversion_helper(nullptr, storage.data()))};
}

View File

@@ -44,14 +44,14 @@ enum class meta_traits : std::uint32_t {
};
template<typename Type>
requires std::is_enum_v<Type>
requires stl::is_enum_v<Type>
[[nodiscard]] auto meta_to_user_traits(const meta_traits traits) noexcept {
constexpr auto shift = std::popcount(static_cast<stl::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits));
return Type{static_cast<stl::underlying_type_t<Type>>(static_cast<stl::underlying_type_t<meta_traits>>(traits) >> shift)};
}
template<typename Type>
requires std::is_enum_v<Type>
requires stl::is_enum_v<Type>
[[nodiscard]] auto user_to_meta_traits(const Type value) noexcept {
constexpr auto shift = std::popcount(static_cast<stl::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits));
const auto traits = static_cast<stl::underlying_type_t<internal::meta_traits>>(static_cast<stl::underlying_type_t<Type>>(value));
@@ -219,7 +219,7 @@ auto setup_node_for() noexcept {
| (std::is_integral_v<Type> ? meta_traits::is_integral : meta_traits::is_none)
| (std::is_signed_v<Type> ? meta_traits::is_signed : meta_traits::is_none)
| (stl::is_array_v<Type> ? meta_traits::is_array : meta_traits::is_none)
| (std::is_enum_v<Type> ? meta_traits::is_enum : meta_traits::is_none)
| (stl::is_enum_v<Type> ? meta_traits::is_enum : meta_traits::is_none)
| (std::is_class_v<Type> ? meta_traits::is_class : meta_traits::is_none)
| (stl::is_pointer_v<Type> ? meta_traits::is_pointer : meta_traits::is_none)
| (is_meta_pointer_like_v<Type> ? meta_traits::is_pointer_like : meta_traits::is_none)
@@ -238,7 +238,7 @@ auto setup_node_for() noexcept {
node.conversion_helper = +[](void *lhs, const void *rhs) {
return lhs ? static_cast<double>(*static_cast<Type *>(lhs) = static_cast<Type>(*static_cast<const double *>(rhs))) : static_cast<double>(*static_cast<const Type *>(rhs));
};
} else if constexpr(std::is_enum_v<Type>) {
} else if constexpr(stl::is_enum_v<Type>) {
node.conversion_helper = +[](void *lhs, const void *rhs) {
return lhs ? static_cast<double>(*static_cast<Type *>(lhs) = static_cast<Type>(static_cast<stl::underlying_type_t<Type>>(*static_cast<const double *>(rhs)))) : static_cast<double>(*static_cast<const Type *>(rhs));
};

View File

@@ -21,6 +21,7 @@ using std::is_convertible_v;
using std::is_copy_assignable_v;
using std::is_copy_constructible_v;
using std::is_default_constructible_v;
using std::is_enum_v;
using std::is_function_v;
using std::is_invocable;
using std::is_invocable_r;