Remove custom implementation for enum hashing

This commit is contained in:
Alexey Rybalchenko 2021-01-14 17:46:15 +01:00
parent 4a09154a91
commit c5487a11ed
2 changed files with 1 additions and 24 deletions

View File

@ -9,7 +9,6 @@
#ifndef FAIR_MQ_TRANSPORTS_H #ifndef FAIR_MQ_TRANSPORTS_H
#define FAIR_MQ_TRANSPORTS_H #define FAIR_MQ_TRANSPORTS_H
#include <fairmq/tools/CppSTL.h>
#include <fairmq/tools/Strings.h> #include <fairmq/tools/Strings.h>
#include <memory> #include <memory>
@ -32,14 +31,6 @@ struct TransportError : std::runtime_error { using std::runtime_error::runtime_e
} // namespace fair::mq } // namespace fair::mq
namespace std
{
template<>
struct hash<fair::mq::Transport> : fair::mq::tools::HashEnum<fair::mq::Transport> {};
} /* namespace std */
namespace fair::mq namespace fair::mq
{ {

View File

@ -9,24 +9,10 @@
#ifndef FAIR_MQ_TOOLS_CPPSTL_H #ifndef FAIR_MQ_TOOLS_CPPSTL_H
#define FAIR_MQ_TOOLS_CPPSTL_H #define FAIR_MQ_TOOLS_CPPSTL_H
#include <functional>
#include <memory>
#include <type_traits>
namespace fair::mq::tools namespace fair::mq::tools
{ {
// provide an enum hasher to compensate std::hash not supporting enums in C++11
template<typename Enum>
struct HashEnum
{
auto operator()(const Enum& e) const noexcept
-> typename std::enable_if<std::is_enum<Enum>::value, std::size_t>::type
{
using _type = typename std::underlying_type<Enum>::type;
return std::hash<_type>{}(static_cast<_type>(e));
}
};
} // namespace fair::mq::tools } // namespace fair::mq::tools