Skip to content

Commit a5168e3

Browse files
authored
Merge pull request #5640 from ab9rf/labor_kitchen_interface_food_key
further updates to support `unordered_map` and `unordered_set`
2 parents f62d79c + b911882 commit a5168e3

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
template<>
2-
struct std::hash<> {
3-
auto operator()(const df::labor_kitchen_interface_food_key &a) const -> size_t {
4-
struct thing {
5-
int16_t t;
6-
int16_t st;
7-
int32_t x;
8-
} thing{
9-
.t = a.type;
10-
.st = a.subtype,
11-
.x = static_cast<int32_t>(a.mat) ^ (static_cast<int32_t>(a.matg))
12-
};
1+
#include <functional>
2+
#include <bit>
3+
#include "df/labor_kitchen_interface_food_key.h"
134

14-
return hash<int64_t>()(bit_cast<int64_t>(thing));
5+
namespace std
6+
{
7+
template<>
8+
struct hash<df::labor_kitchen_interface_food_key>
9+
{
10+
auto operator()(const df::labor_kitchen_interface_food_key& a) const -> size_t
11+
{
12+
struct thing
13+
{
14+
int16_t t;
15+
int16_t st;
16+
int32_t x;
17+
} thing{
18+
.t = a.type,
19+
.st = a.subtype,
20+
.x = static_cast<int32_t>(a.mat) ^ (static_cast<int32_t>(a.matg))
21+
};
22+
23+
return hash<int64_t>()(std::bit_cast<int64_t>(thing));
1524
}
1625
};
26+
}

0 commit comments

Comments
 (0)