According to the C++ standard, it is not allowed to add an overload of any function inside the namespace std. Practically, I think adding an overload of std::swap for a user-defined type may almost never cause any problem, but technically speaking this is strictly banned by the standard and can lead to an undefined behavior.
AFAIK, the idiomatic way of "specializing" functions like std::swap is to rely on ADL. That means, the "specialization" of swap must be inside the namespace where cuckoohash_map is defined. Since cuckoohash_map is inside the global namespace, its corresponding swap should also be inside the global namespace. This sounds not good, and I strongly suggest you to wrap everything in this library inside a namespace.
Good point! I wrapped everything inside a libcuckoo namespace, and put the swap specialization inside this namespace. c75a843f079315ba3fd6b53a992755fa2a15a1bb.
According to the C++ standard, it is not allowed to add an overload of any function inside the namespace std. Practically, I think adding an overload of
std::swap
for a user-defined type may almost never cause any problem, but technically speaking this is strictly banned by the standard and can lead to an undefined behavior.AFAIK, the idiomatic way of "specializing" functions like
std::swap
is to rely on ADL. That means, the "specialization" ofswap
must be inside the namespace wherecuckoohash_map
is defined. Sincecuckoohash_map
is inside the global namespace, its correspondingswap
should also be inside the global namespace. This sounds not good, and I strongly suggest you to wrap everything in this library inside a namespace.