martinus / robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
https://gitter.im/martinus/robin-hood-hashing
MIT License
1.5k stars 143 forks source link

Consider porting to C++11 / C++03 #32

Closed asbai closed 5 years ago

asbai commented 5 years ago

A large number of development environments still do not have C++14 support, especially in many embedded environments that only support C++03.

Can you consider porting this powerful and efficient container to these older versions?

Thanks :-)

cloudhan commented 5 years ago

Actually making a C++11 compatible version is quiet simple. I can make a PR after confirming LICENSE of the code snippet.

martinus commented 5 years ago

I accept pull requests :)

martinus commented 5 years ago

Ported to C++11 by @cloudhan. Thanks again!

asbai commented 5 years ago

Sorry for reopen it, but due to GCC not support is_trivially_copyable until version 5. So even if we specify -std=c++11, we still can't use this great container on GCC 4.9 and earlier toolchains.

To solve this problem, we have added the following macro definition to it:

#if defined(__GNUC__) && __GNUC__ < 5
#    define is_trivially_copyable is_trivial
#endif

And this patch works well on GCC 4.9.

martinus commented 5 years ago

I've added a travis build for g++4.9 and added a similar workaround, but with __has_trivial_copy. (see https://github.com/martinus/robin-hood-hashing/commit/888b2a3cd5bbb84ca986183828c0db851faf1101#diff-d2088bf6a93bf905b42d89a70f3acdabR149) Can you check if the latest version https://github.com/martinus/robin-hood-hashing/blob/master/src/include/robin_hood.h works for you?

asbai commented 5 years ago

hi @martinus , thanks for your quick response. I have compiled and tested on gcc 4.9.4 (linux_x64) and gcc 4.9.2 (msw_x64) for your new version. And everything seems to work very well. :-)

martinus commented 5 years ago

Awesome