Fix copy assignment warning in gcc

This commit is contained in:
Christian Mazakas
2023-04-12 12:22:38 -07:00
parent 2226a7238d
commit b771278813
2 changed files with 37 additions and 3 deletions

View File

@ -173,7 +173,15 @@ struct atomic_integral
void operator|=(Integral m){n.fetch_or(m,std::memory_order_relaxed);} void operator|=(Integral m){n.fetch_or(m,std::memory_order_relaxed);}
void operator&=(Integral m){n.fetch_and(m,std::memory_order_relaxed);} void operator&=(Integral m){n.fetch_and(m,std::memory_order_relaxed);}
atomic_integral& operator=(atomic_integral const& rhs) {
if(this!=&rhs){
n.store(rhs.n.load(std::memory_order_relaxed),std::memory_order_relaxed);
}
return *this;
}
std::atomic<Integral> n; std::atomic<Integral> n;
}; };
/* Group-level concurrency protection. It provides a rw mutex plus an /* Group-level concurrency protection. It provides a rw mutex plus an

View File

@ -1773,9 +1773,7 @@ private:
{ {
if(arrays.elements){ if(arrays.elements){
copy_elements_array_from(x); copy_elements_array_from(x);
std::memcpy( copy_groups_array_from(x);
arrays.groups,x.arrays.groups,
(arrays.groups_size_mask+1)*sizeof(group_type));
size_=std::size_t(x.size_); size_=std::size_t(x.size_);
} }
} }
@ -1833,6 +1831,34 @@ private:
BOOST_CATCH_END BOOST_CATCH_END
} }
void copy_groups_array_from(const table_core& x) {
copy_groups_array_from(x, std::integral_constant<bool,
#if BOOST_WORKAROUND(BOOST_LIBSTDCXX_VERSION,<50000)
/* std::is_trivially_copyable not provided */
boost::has_trivial_copy<element_type>::value
#else
std::is_trivially_copyable<element_type>::value
#endif
>{}
);
}
void copy_groups_array_from(
const table_core& x, std::true_type /* -> memcpy */)
{
std::memcpy(
arrays.groups,x.arrays.groups,
(arrays.groups_size_mask+1)*sizeof(group_type));
}
void copy_groups_array_from(
const table_core& x, std::false_type /* -> manual */)
{
for(std::size_t i=0;i<arrays.groups_size_mask+1;++i){
arrays.groups[i]=x.arrays.groups[i];
}
}
void recover_slot(unsigned char* pc) void recover_slot(unsigned char* pc)
{ {
/* If this slot potentially caused overflow, we decrease the maximum load so /* If this slot potentially caused overflow, we decrease the maximum load so