From 8382bc2dcfe613652f59c3118fa21d47b874f647 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 7 Apr 2024 10:03:14 +0200 Subject: use static_cast on void* instead of reinterpret_cast --- entity/metadata.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'entity') diff --git a/entity/metadata.hpp b/entity/metadata.hpp index 3da3dcb0..101af0df 100644 --- a/entity/metadata.hpp +++ b/entity/metadata.hpp @@ -158,20 +158,20 @@ constexpr erased_accessor entity_field::erased() const constexpr auto obj_name = name_of, field_name = name_of; constexpr auto reader_fn = [](const void* obj, const reader_t* reader, void* value) { - const auto& obj_ = *reinterpret_cast(obj); - const auto& reader_ = *reinterpret_cast(reader); - auto& value_ = *reinterpret_cast(value); + const auto& obj_ = *static_cast(obj); + const auto& reader_ = *static_cast(reader); + auto& value_ = *static_cast(value); value_ = read(reader_, obj_); }; constexpr auto writer_fn = [](void* obj, const writer_t* writer, void* value) { - auto& obj_ = *reinterpret_cast(obj); - const auto& writer_ = *reinterpret_cast(writer); - Type value_ = move(*reinterpret_cast(value)); + auto& obj_ = *static_cast(obj); + const auto& writer_ = *static_cast(writer); + Type value_ = move(*static_cast(value)); write(writer_, obj_, move(value_)); }; constexpr auto predicate_fn = [](const void* obj, const predicate_t* predicate) { - const auto& obj_ = *reinterpret_cast(obj); - const auto& predicate_ = *reinterpret_cast(predicate); + const auto& obj_ = *static_cast(obj); + const auto& predicate_ = *static_cast(predicate); return is_enabled(predicate_, obj_); }; constexpr auto writer_stub_fn = [](void*, const writer_t*, void*) { @@ -180,10 +180,10 @@ constexpr erased_accessor entity_field::erased() const constexpr bool has_writer = !std::is_same_v, std::nullptr_t>; constexpr auto c_range_fn = [](const void* obj, const c_range_t* reader) -> erased_constraints::range { - return get_range(*reinterpret_cast(reader), *reinterpret_cast(obj)); + return get_range(*static_cast(reader), *reinterpret_cast(obj)); }; constexpr auto c_length_fn = [](const void* obj, const c_length_t* reader) -> erased_constraints::max_length { - return get_max_length(*reinterpret_cast(reader), *reinterpret_cast(obj)); + return get_max_length(*static_cast(reader), *reinterpret_cast(obj)); }; return erased_accessor { (void*)&reader, has_writer ? (void*)&writer : nullptr, -- cgit v1.2.3