Compile fails for data objects that has copy constructor deleted
zhqrbitee opened this issue · 1 comments
zhqrbitee commented
If the data object has its copy constructor deleted, e.g.
class Data {
public:
Data(....) {...};
Data(const Data&) = delete;
Data(Data&&) { ...; }
Data &operator=(const Data &other) = delete;
Data &operator=(Data &&other) noexcept { ...; }
}
Compilation will fail:
emhash/hash_table6.hpp:1438:41: note: in instantiation of member function 'emhash6::...::operator=' requested here
if (is_copy_trivially())
EMH_PKV(_pairs, bucket) = EMH_PKV(_pairs, next_bucket); <---
else
EMH_PKV(_pairs, bucket).swap(EMH_PKV(_pairs, next_bucket));
Compiler will try to compile both branches so it fails.
If we are in C++17, a easy fixes would be mark the branch with constexpr
, so the compiler won't compile the first branch.
ktprime commented
emhash is flat hash map which must support c++11/14, and key/value must be swappable or copy/move constructible
it will be changed to
EMH_PKV(_pairs, bucket) = std::move(EMH_PKV(_pairs, next_bucket));