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

any: try to trick code coverage tools

Michele Caini 1 год назад
Родитель
Сommit
5cf82d9b3b
1 измененных файлов с 14 добавлено и 14 удалено
  1. 14 14
      src/entt/core/any.hpp

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

@@ -17,12 +17,12 @@ namespace entt {
 namespace internal {
 namespace internal {
 
 
 enum class any_operation : std::uint8_t {
 enum class any_operation : std::uint8_t {
-    copy,
-    move,
     transfer,
     transfer,
     assign,
     assign,
     destroy,
     destroy,
     compare,
     compare,
+    copy,
+    move,
     get
     get
 };
 };
 
 
@@ -73,17 +73,6 @@ class basic_any {
         }
         }
 
 
         switch(op) {
         switch(op) {
-        case operation::copy:
-            if constexpr(std::is_copy_constructible_v<Type>) {
-                static_cast<basic_any *>(const_cast<void *>(other))->initialize<Type>(*elem);
-            }
-            break;
-        case operation::move:
-            ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy type");
-            if constexpr(in_situ<Type>) {
-                return ::new(&static_cast<basic_any *>(const_cast<void *>(other))->storage) Type{std::move(*const_cast<Type *>(elem))};
-            }
-            break;
         case operation::transfer:
         case operation::transfer:
             if constexpr(std::is_move_assignable_v<Type>) {
             if constexpr(std::is_move_assignable_v<Type>) {
                 *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)));
@@ -111,12 +100,23 @@ class basic_any {
             } else {
             } else {
                 return (elem == other) ? other : nullptr;
                 return (elem == other) ? other : nullptr;
             }
             }
+        case operation::copy:
+            if constexpr(std::is_copy_constructible_v<Type>) {
+                static_cast<basic_any *>(const_cast<void *>(other))->initialize<Type>(*elem);
+            }
+            break;
+        case operation::move:
+            ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy type");
+            if constexpr(in_situ<Type>) {
+                return ::new(&static_cast<basic_any *>(const_cast<void *>(other))->storage) Type{std::move(*const_cast<Type *>(elem))};
+            }
+            [[fallthrough]];
         case operation::get:
         case operation::get:
             ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy type");
             ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy type");
             if constexpr(in_situ<Type>) {
             if constexpr(in_situ<Type>) {
                 return elem;
                 return elem;
             }
             }
-            break;
+            [[fallthrough]];
         }
         }
 
 
         return nullptr;
         return nullptr;