Skip to content

Commit

Permalink
Add custom hash function for the unordered map.
Browse files Browse the repository at this point in the history
The unordered map uses a scoped enums as keys. We implement a
custom hash function to handle hashing of those enum values.
  • Loading branch information
vahancho committed Feb 5, 2024
1 parent b4abadf commit 6ca2dad
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/coordinate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@
namespace erkir
{

using RxList = std::unordered_map<Coordinate::Format, std::wregex>;
template <typename T>
struct FormatHash
{
std::size_t operator()(const T &type) const
{
return static_cast<std::size_t>(type);
}
};

using RxList = std::unordered_map<Coordinate::Format, std::wregex,
FormatHash<Coordinate::Format>>;

constexpr double radiansInDegree = M_PI / 180.0;

Expand Down

0 comments on commit 6ca2dad

Please sign in to comment.