Quellcode durchsuchen

stl: std::is_const_v

skypjack vor 21 Stunden
Ursprung
Commit
69331f4796

+ 4 - 4
src/entt/core/any.hpp

@@ -138,7 +138,7 @@ class basic_any: private internal::basic_any_storage<Len, Align> {
             this->instance = nullptr;
         } else if constexpr(stl::is_lvalue_reference_v<Type>) {
             deleter = nullptr;
-            mode = std::is_const_v<stl::remove_reference_t<Type>> ? any_policy::cref : any_policy::ref;
+            mode = stl::is_const_v<stl::remove_reference_t<Type>> ? any_policy::cref : any_policy::ref;
             static_assert((stl::is_lvalue_reference_v<Args> && ...) && (sizeof...(Args) == 1u), "Invalid arguments");
             // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
             this->instance = (std::addressof(args), ...);
@@ -206,7 +206,7 @@ public:
      * @param value A pointer to an object to take ownership of.
      */
     template<typename Type>
-    requires (!std::is_const_v<Type> && !stl::is_void_v<Type>)
+    requires (!stl::is_const_v<Type> && !stl::is_void_v<Type>)
     explicit basic_any(std::in_place_t, Type *value)
         : base_type{} {
         if(value == nullptr) {
@@ -409,7 +409,7 @@ public:
      */
     template<typename Type>
     [[nodiscard]] Type *data() noexcept {
-        if constexpr(std::is_const_v<Type>) {
+        if constexpr(stl::is_const_v<Type>) {
             return stl::as_const(*this).template data<stl::remove_const_t<Type>>();
         } else {
             return (mode == any_policy::cref) ? nullptr : const_cast<Type *>(stl::as_const(*this).template data<stl::remove_const_t<Type>>());
@@ -582,7 +582,7 @@ template<typename Type, std::size_t Len, std::size_t Align>
 /*! @copydoc any_cast */
 template<typename Type, std::size_t Len, std::size_t Align>
 [[nodiscard]] Type *any_cast(basic_any<Len, Align> *data) noexcept {
-    if constexpr(std::is_const_v<Type>) {
+    if constexpr(stl::is_const_v<Type>) {
         // last attempt to make wrappers for const references return their values
         return any_cast<Type>(&stl::as_const(*data));
     } else {

+ 1 - 1
src/entt/entity/helper.hpp

@@ -61,7 +61,7 @@ template<typename Registry>
 class as_group {
     template<typename... Owned, typename... Get, typename... Exclude>
     [[nodiscard]] auto dispatch(owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>) const {
-        if constexpr(std::is_const_v<registry_type>) {
+        if constexpr(stl::is_const_v<registry_type>) {
             return reg->template group_if_exists<typename Owned::element_type...>(get_t<typename Get::element_type...>{}, exclude_t<typename Exclude::element_type...>{});
         } else {
             return reg->template group<constness_as_t<typename Owned::element_type, Owned>...>(get_t<constness_as_t<typename Get::element_type, Get>...>{}, exclude_t<constness_as_t<typename Exclude::element_type, Exclude>...>{});

+ 1 - 1
src/entt/entity/mixin.hpp

@@ -570,7 +570,7 @@ public:
     template<typename... Get, typename... Exclude>
     [[nodiscard]] basic_view<get_t<const basic_reactive_mixin, typename basic_registry_type::template storage_for_type<Get>...>, exclude_t<typename basic_registry_type::template storage_for_type<Exclude>...>>
     view(exclude_t<Exclude...> = exclude_t{}) {
-        std::conditional_t<((std::is_const_v<Get> && ...) && (std::is_const_v<Exclude> && ...)), const owner_type, owner_type> &parent = owner_or_assert();
+        std::conditional_t<((stl::is_const_v<Get> && ...) && (stl::is_const_v<Exclude> && ...)), const owner_type, owner_type> &parent = owner_or_assert();
         return {*this, parent.template storage<stl::remove_const_t<Get>>()..., parent.template storage<stl::remove_const_t<Exclude>>()...};
     }
 

+ 2 - 2
src/entt/entity/organizer.hpp

@@ -39,12 +39,12 @@ inline constexpr bool is_group_v = is_group<Type>::value;
 template<typename Type, typename Override>
 struct unpack_type {
     using ro = std::conditional_t<
-        type_list_contains_v<Override, const Type> || (std::is_const_v<Type> && !type_list_contains_v<Override, stl::remove_const_t<Type>>),
+        type_list_contains_v<Override, const Type> || (stl::is_const_v<Type> && !type_list_contains_v<Override, stl::remove_const_t<Type>>),
         type_list<stl::remove_const_t<Type>>,
         type_list<>>;
 
     using rw = std::conditional_t<
-        type_list_contains_v<Override, stl::remove_const_t<Type>> || (!std::is_const_v<Type> && !type_list_contains_v<Override, const Type>),
+        type_list_contains_v<Override, stl::remove_const_t<Type>> || (!stl::is_const_v<Type> && !type_list_contains_v<Override, const Type>),
         type_list<Type>,
         type_list<>>;
 };

+ 3 - 3
src/entt/entity/snapshot.hpp

@@ -43,7 +43,7 @@ void orphans(Registry &registry) {
  */
 template<typename Registry>
 class basic_snapshot {
-    static_assert(!std::is_const_v<Registry>, "Non-const registry type required");
+    static_assert(!stl::is_const_v<Registry>, "Non-const registry type required");
     using traits_type = entt_traits<typename Registry::entity_type>;
 
 public:
@@ -171,7 +171,7 @@ private:
  */
 template<typename Registry>
 class basic_snapshot_loader {
-    static_assert(!std::is_const_v<Registry>, "Non-const registry type required");
+    static_assert(!stl::is_const_v<Registry>, "Non-const registry type required");
     using traits_type = entt_traits<typename Registry::entity_type>;
 
 public:
@@ -301,7 +301,7 @@ private:
  */
 template<typename Registry>
 class basic_continuous_loader {
-    static_assert(!std::is_const_v<Registry>, "Non-const registry type required");
+    static_assert(!stl::is_const_v<Registry>, "Non-const registry type required");
     using traits_type = entt_traits<typename Registry::entity_type>;
 
     void restore(Registry::entity_type entt) {

+ 2 - 2
src/entt/entity/storage.hpp

@@ -35,7 +35,7 @@ class storage_iterator final {
     using alloc_traits = std::allocator_traits<typename container_type::allocator_type>;
 
     using iterator_traits = stl::iterator_traits<std::conditional_t<
-        std::is_const_v<Container>,
+        stl::is_const_v<Container>,
         typename alloc_traits::template rebind_traits<typename std::pointer_traits<typename container_type::value_type>::element_type>::const_pointer,
         typename alloc_traits::template rebind_traits<typename std::pointer_traits<typename container_type::value_type>::element_type>::pointer>>;
 
@@ -53,7 +53,7 @@ public:
           offset{idx} {}
 
     template<std::same_as<stl::remove_const_t<Container>> Other>
-    requires std::is_const_v<Container>
+    requires stl::is_const_v<Container>
     constexpr storage_iterator(const storage_iterator<Other, Page> &other) noexcept
         : storage_iterator{other.payload, other.offset} {}
 

+ 2 - 2
src/entt/meta/factory.hpp

@@ -363,7 +363,7 @@ public:
                     id,
                     name,
                     /* this is never static */
-                    std::is_const_v<stl::remove_reference_t<data_type>> ? internal::meta_traits::is_const : internal::meta_traits::is_none,
+                    stl::is_const_v<stl::remove_reference_t<data_type>> ? internal::meta_traits::is_const : internal::meta_traits::is_none,
                     1u,
                     &internal::resolve<stl::remove_cvref_t<data_type>>,
                     &meta_arg<type_list<stl::remove_cvref_t<data_type>>>,
@@ -382,7 +382,7 @@ public:
                 internal::meta_data_node{
                     id,
                     name,
-                    ((!stl::is_pointer_v<decltype(Data)> || std::is_const_v<data_type>) ? internal::meta_traits::is_const : internal::meta_traits::is_none) | internal::meta_traits::is_static,
+                    ((!stl::is_pointer_v<decltype(Data)> || stl::is_const_v<data_type>) ? internal::meta_traits::is_const : internal::meta_traits::is_none) | internal::meta_traits::is_static,
                     1u,
                     &internal::resolve<stl::remove_cvref_t<data_type>>,
                     &meta_arg<type_list<stl::remove_cvref_t<data_type>>>,

+ 5 - 5
src/entt/meta/meta.hpp

@@ -76,7 +76,7 @@ public:
           begin_end_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::iter},
           insert_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::insert},
           erase_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::erase},
-          const_only{std::is_const_v<Type>} {}
+          const_only{stl::is_const_v<Type>} {}
 
     [[nodiscard]] inline meta_type value_type() const noexcept;
     [[nodiscard]] inline size_type size() const noexcept;
@@ -137,7 +137,7 @@ public:
           insert_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::insert},
           erase_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::erase},
           find_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::find},
-          const_only{std::is_const_v<Type>} {
+          const_only{stl::is_const_v<Type>} {
         if constexpr(!meta_associative_container_traits<stl::remove_const_t<Type>>::key_only) {
             mapped_type_node = &internal::resolve<typename Type::mapped_type>;
         }
@@ -449,7 +449,7 @@ public:
     /*! @copydoc try_cast */
     template<typename Type>
     [[nodiscard]] Type *try_cast() {
-        return ((storage.policy() == any_policy::cref) && !std::is_const_v<Type>) ? nullptr : const_cast<Type *>(stl::as_const(*this).try_cast<stl::remove_const_t<Type>>());
+        return ((storage.policy() == any_policy::cref) && !stl::is_const_v<Type>) ? nullptr : const_cast<Type *>(stl::as_const(*this).try_cast<stl::remove_const_t<Type>>());
     }
 
     /**
@@ -494,7 +494,7 @@ public:
      */
     template<typename Type>
     [[nodiscard]] meta_any allow_cast() const {
-        if constexpr(!std::is_reference_v<Type> || std::is_const_v<stl::remove_reference_t<Type>>) {
+        if constexpr(!std::is_reference_v<Type> || stl::is_const_v<stl::remove_reference_t<Type>>) {
             if(storage.has_value<stl::remove_cvref_t<Type>>()) {
                 return as_ref();
             } else if(*this) {
@@ -530,7 +530,7 @@ public:
      */
     template<typename Type>
     [[nodiscard]] bool allow_cast() {
-        if constexpr(std::is_reference_v<Type> && !std::is_const_v<stl::remove_reference_t<Type>>) {
+        if constexpr(std::is_reference_v<Type> && !stl::is_const_v<stl::remove_reference_t<Type>>) {
             return allow_cast<const stl::remove_reference_t<Type> &>() && (storage.policy() != any_policy::cref);
         } else {
             if(storage.has_value<stl::remove_cvref_t<Type>>()) {

+ 1 - 1
src/entt/meta/policy.hpp

@@ -33,7 +33,7 @@ struct as_void_t final: private internal::meta_policy {
 struct as_ref_t final: private internal::meta_policy {
     /*! @cond ENTT_INTERNAL */
     template<typename Type>
-    static constexpr bool value = std::is_reference_v<Type> && !std::is_const_v<stl::remove_reference_t<Type>>;
+    static constexpr bool value = std::is_reference_v<Type> && !stl::is_const_v<stl::remove_reference_t<Type>>;
     /*! @endcond */
 };
 

+ 3 - 3
src/entt/meta/utility.hpp

@@ -97,7 +97,7 @@ struct meta_function_descriptor<Type, Ret (*)(MaybeType, Args...)>
               type_list<Args...>,
               type_list<MaybeType, Args...>>,
           !(stl::is_same_v<stl::remove_cvref_t<MaybeType>, Type> || std::is_base_of_v<stl::remove_cvref_t<MaybeType>, Type>),
-          std::is_const_v<stl::remove_reference_t<MaybeType>> && (stl::is_same_v<stl::remove_cvref_t<MaybeType>, Type> || std::is_base_of_v<stl::remove_cvref_t<MaybeType>, Type>)> {};
+          stl::is_const_v<stl::remove_reference_t<MaybeType>> && (stl::is_same_v<stl::remove_cvref_t<MaybeType>, Type> || std::is_base_of_v<stl::remove_cvref_t<MaybeType>, Type>)> {};
 
 /**
  * @brief Meta function descriptor.
@@ -286,7 +286,7 @@ template<typename Type, auto Data>
     } else if constexpr(stl::is_member_object_pointer_v<decltype(Data)>) {
         using data_type = stl::remove_reference_t<typename meta_function_helper_t<Type, decltype(Data)>::return_type>;
 
-        if constexpr(!std::is_array_v<data_type> && !std::is_const_v<data_type>) {
+        if constexpr(!std::is_array_v<data_type> && !stl::is_const_v<data_type>) {
             if(auto *const clazz = instance->try_cast<Type>(); clazz && value.allow_cast<data_type>()) {
                 std::invoke(Data, *clazz) = value.cast<data_type>();
                 return true;
@@ -295,7 +295,7 @@ template<typename Type, auto Data>
     } else if constexpr(stl::is_pointer_v<decltype(Data)>) {
         using data_type = stl::remove_reference_t<decltype(*Data)>;
 
-        if constexpr(!std::is_array_v<data_type> && !std::is_const_v<data_type>) {
+        if constexpr(!std::is_array_v<data_type> && !stl::is_const_v<data_type>) {
             if(value.allow_cast<data_type>()) {
                 *Data = value.cast<data_type>();
                 return true;

+ 1 - 0
src/entt/stl/type_traits.hpp

@@ -10,6 +10,7 @@ using std::decay_t;
 using std::false_type;
 using std::invoke_result_t;
 using std::is_aggregate_v;
+using std::is_const_v;
 using std::is_default_constructible_v;
 using std::is_invocable_r_v;
 using std::is_lvalue_reference_v;