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

The library is not working when compiled with -fno-exceptions #41

Closed silviucpp closed 4 years ago

silviucpp commented 4 years ago

Hello,

Unfortunately for projects compiled with -fno-exceptions you can't use the library and need to stick with std:: one. Any plan to support also this ?

Silviu

martinus commented 4 years ago

I don't really know anything about that use case. Why would a project use -fno-exceptions? What does the std map do when allocation fails?

silviucpp commented 4 years ago

Hello,

I have no idea what stl is doing. But because google is not using exceptions into their projects: https://google.github.io/styleguide/cppguide.html#Exceptions lot of their projects are built with -fno-exceptions. STL for some reason works ok but when trying to replace std::unordered_map with your lib it's not longer compiling if not dropping -fno-exceptions

Silviu

martinus commented 4 years ago

Ok it seems the stl simply replaced all throws with abort() with that flag. I think this should be simple to add. See https://stackoverflow.com/a/7249442 and https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html

silviucpp commented 4 years ago

Oh I see.. good to know. Anyway if you are working with google open source projects most of them are compiled with -fno-exceptions. So supporting this might be a good idea.

Silviu

martinus commented 4 years ago

Can you try if this latest version works for you: https://raw.githubusercontent.com/martinus/robin-hood-hashing/master/src/include/robin_hood.h

martinus commented 4 years ago

closing, as it works for me in my builds (even tests work)