Skip to content

Commit

Permalink
any: I know what I'm doing, I don't want to cast things explicitly an…
Browse files Browse the repository at this point in the history
…d make it harder to read
  • Loading branch information
skypjack committed Jan 27, 2025
1 parent 9ae5a3d commit 08b21b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/entt/core/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ class basic_any {
case request::move:
ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy");
if constexpr(in_situ<Type>) {
// NOLINTNEXTLINE(bugprone-casting-through-void)
return static_cast<const void *>(::new(&static_cast<basic_any *>(const_cast<void *>(other))->storage) Type{std::move(*const_cast<Type *>(elem))});
// NOLINTNEXTLINE(bugprone-casting-through-void,bugprone-multi-level-implicit-pointer-conversion)
return ::new(&static_cast<basic_any *>(const_cast<void *>(other))->storage) Type{std::move(*const_cast<Type *>(elem))};
}
[[fallthrough]];
case request::get:
ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy");
if constexpr(in_situ<Type>) {
return static_cast<const void *>(elem);
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
return elem;
}
}

Expand All @@ -122,6 +123,7 @@ class basic_any {
if constexpr(std::is_lvalue_reference_v<Type>) {
static_assert((std::is_lvalue_reference_v<Args> && ...) && (sizeof...(Args) == 1u), "Invalid arguments");
mode = std::is_const_v<std::remove_reference_t<Type>> ? any_policy::cref : any_policy::ref;
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
instance = (std::addressof(args), ...);
} else if constexpr(in_situ<plain_type>) {
mode = any_policy::embedded;
Expand Down

0 comments on commit 08b21b1

Please sign in to comment.