Просмотр исходного кода

any/meta_any: suppress bugprone-casting-through-void as needed

Michele Caini 1 год назад
Родитель
Сommit
48872e7ef8
2 измененных файлов с 6 добавлено и 0 удалено
  1. 3 0
      src/entt/core/any.hpp
  2. 3 0
      src/entt/meta/meta.hpp

+ 3 - 0
src/entt/core/any.hpp

@@ -61,6 +61,7 @@ class basic_any {
         switch(req) {
         switch(req) {
         case request::transfer:
         case request::transfer:
             if constexpr(std::is_move_assignable_v<Type>) {
             if constexpr(std::is_move_assignable_v<Type>) {
+                // NOLINTNEXTLINE(bugprone-casting-through-void)
                 *const_cast<Type *>(elem) = std::move(*static_cast<Type *>(const_cast<void *>(other)));
                 *const_cast<Type *>(elem) = std::move(*static_cast<Type *>(const_cast<void *>(other)));
                 return other;
                 return other;
             }
             }
@@ -88,12 +89,14 @@ class basic_any {
             }
             }
         case request::copy:
         case request::copy:
             if constexpr(std::is_copy_constructible_v<Type>) {
             if constexpr(std::is_copy_constructible_v<Type>) {
+                // NOLINTNEXTLINE(bugprone-casting-through-void)
                 static_cast<basic_any *>(const_cast<void *>(other))->initialize<Type>(*elem);
                 static_cast<basic_any *>(const_cast<void *>(other))->initialize<Type>(*elem);
             }
             }
             break;
             break;
         case request::move:
         case request::move:
             ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy");
             ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy");
             if constexpr(in_situ<Type>) {
             if constexpr(in_situ<Type>) {
+                // NOLINTNEXTLINE(bugprone-casting-through-void)
                 return ::new(&static_cast<basic_any *>(const_cast<void *>(other))->storage) Type{std::move(*const_cast<Type *>(elem))};
                 return ::new(&static_cast<basic_any *>(const_cast<void *>(other))->storage) Type{std::move(*const_cast<Type *>(elem))};
             }
             }
             [[fallthrough]];
             [[fallthrough]];

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

@@ -190,12 +190,14 @@ class meta_any {
 
 
         if constexpr(is_complete_v<meta_sequence_container_traits<Type>>) {
         if constexpr(is_complete_v<meta_sequence_container_traits<Type>>) {
             if(!!(req & internal::meta_traits::is_sequence_container)) {
             if(!!(req & internal::meta_traits::is_sequence_container)) {
+                // NOLINTNEXTLINE(bugprone-casting-through-void)
                 *static_cast<meta_sequence_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_sequence_container{area, *static_cast<const Type *>(value)} : meta_sequence_container{area, *static_cast<Type *>(const_cast<void *>(value))};
                 *static_cast<meta_sequence_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_sequence_container{area, *static_cast<const Type *>(value)} : meta_sequence_container{area, *static_cast<Type *>(const_cast<void *>(value))};
             }
             }
         }
         }
 
 
         if constexpr(is_complete_v<meta_associative_container_traits<Type>>) {
         if constexpr(is_complete_v<meta_associative_container_traits<Type>>) {
             if(!!(req & internal::meta_traits::is_associative_container)) {
             if(!!(req & internal::meta_traits::is_associative_container)) {
+                // NOLINTNEXTLINE(bugprone-casting-through-void)
                 *static_cast<meta_associative_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_associative_container{area, *static_cast<const Type *>(value)} : meta_associative_container{area, *static_cast<Type *>(const_cast<void *>(value))};
                 *static_cast<meta_associative_container *>(other) = !!(req & internal::meta_traits::is_const) ? meta_associative_container{area, *static_cast<const Type *>(value)} : meta_associative_container{area, *static_cast<Type *>(const_cast<void *>(value))};
             }
             }
         }
         }
@@ -450,6 +452,7 @@ public:
             return std::as_const(*this).try_cast<std::remove_const_t<Type>>();
             return std::as_const(*this).try_cast<std::remove_const_t<Type>>();
         } else {
         } else {
             const auto &other = type_id<Type>();
             const auto &other = type_id<Type>();
+            // NOLINTNEXTLINE(bugprone-casting-through-void)
             return static_cast<Type *>(const_cast<void *>(internal::try_cast(internal::meta_context::from(*ctx), node, other, storage.data())));
             return static_cast<Type *>(const_cast<void *>(internal::try_cast(internal::meta_context::from(*ctx), node, other, storage.data())));
         }
         }
     }
     }