netlist: clearly identify void * casts.

This commit is contained in:
couriersud 2020-09-24 07:53:46 +02:00
parent 1fffeb33c0
commit dd5769bea9
4 changed files with 9 additions and 5 deletions

View File

@ -112,13 +112,13 @@ namespace netlist
template<typename O, typename C>
void save(O &owner, C &state, const pstring &module, const pstring &stname)
{
this->run_state_manager().save_item(static_cast<void *>(&owner), state, module + "." + stname);
this->run_state_manager().save_item(plib::void_ptr_cast(&owner), state, module + "." + stname);
}
template<typename O, typename C>
void save(O &owner, C *state, const pstring &module, const pstring &stname, const std::size_t count)
{
this->run_state_manager().save_state_ptr(static_cast<void *>(&owner), module + "." + stname, plib::state_manager_t::dtype<C>(), count, state);
this->run_state_manager().save_state_ptr(plib::void_ptr_cast(&owner), module + "." + stname, plib::state_manager_t::dtype<C>(), count, state);
}
// FIXME: only used by queue_t save state

View File

@ -125,7 +125,7 @@
/// This is about 10% slower on a skylake processor for pongf.
///
#ifndef NL_PREFER_INT128
#define NL_PREFER_INT128 (1)
#define NL_PREFER_INT128 (0)
#endif
/// \brief Support float type for matrix calculations.

View File

@ -288,7 +288,7 @@ namespace plib {
void construct(U* p, Args&&... args)
{
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
::new (static_cast<void *>(p)) U(std::forward<Args>(args)...);
::new (void_ptr_cast(p)) U(std::forward<Args>(args)...);
}
template<typename U>

View File

@ -93,7 +93,7 @@ namespace plib {
/// and later for debug builds use dynamic_cast.
///
template <typename D, typename B>
inline constexpr D downcast(B && b) noexcept
constexpr D downcast(B && b) noexcept
{
static_assert(std::is_pointer<D>::value || std::is_reference<D>::value, "downcast only supports pointers or reference for derived");
static_assert(std::is_pointer<B>::value || std::is_reference<B>::value, "downcast only supports pointers or reference for base");
@ -101,6 +101,10 @@ namespace plib {
}
using pgsl::narrow_cast;
template <typename T>
constexpr void * void_ptr_cast(T *ptr) noexcept { return static_cast<void *>(ptr); }
} // namespace plib
//FIXME: This is the place to use more complete implementations