Skip to content

Commit

Permalink
any: try to trick code coverage tools
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Nov 20, 2024
1 parent e095c33 commit 5cf82d9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/entt/core/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespace entt {
namespace internal {

enum class any_operation : std::uint8_t {
copy,
move,
transfer,
assign,
destroy,
compare,
copy,
move,
get
};

Expand Down Expand Up @@ -73,17 +73,6 @@ class basic_any {
}

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:
if constexpr(std::is_move_assignable_v<Type>) {
*const_cast<Type *>(elem) = std::move(*static_cast<Type *>(const_cast<void *>(other)));
Expand Down Expand Up @@ -111,12 +100,23 @@ class basic_any {
} else {
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:
ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy type");
if constexpr(in_situ<Type>) {
return elem;
}
break;
[[fallthrough]];
}

return nullptr;
Expand Down

0 comments on commit 5cf82d9

Please sign in to comment.