forked from stepmania/stepmania
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIDUtil.h
45 lines (43 loc) · 1.04 KB
/
IDUtil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef ID_UTIL_H
#define ID_UTIL_H
// This is a specialization of the std::hash template for handling the various
// types that have ToString functions, so they can be used in unordered_map.
// It is based on this example: http://en.cppreference.com/w/cpp/utility/hash
// I haven't figured out how to use templates right yet, so I copy pasted to
// cover all our custom types. -Kyz
namespace std
{
template<>
struct hash<SongID>
{
std::size_t operator()(SongID const& s) const
{
return std::hash<std::string>()(std::string(s.ToString()));
}
};
template<>
struct hash<CourseID>
{
std::size_t operator()(CourseID const& s) const
{
return std::hash<std::string>()(std::string(s.ToString()));
}
};
template<>
struct hash<StepsID>
{
std::size_t operator()(StepsID const& s) const
{
return std::hash<std::string>()(std::string(s.ToString()));
}
};
template<>
struct hash<TrailID>
{
std::size_t operator()(TrailID const& s) const
{
return std::hash<std::string>()(std::string(s.ToString()));
}
};
}
#endif