Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 97b9fce

Browse files
authored
Merge pull request #101 from cyanray/dev/cyanray
让UID_t、QQ_t、GID_t支持map、unordered_map容器。
2 parents c0f83cd + d934740 commit 97b9fce

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

include/mirai/defs/qq_types.hpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <exception>
66
#include <iostream>
7+
#include <functional>
78
#include "serializable.hpp"
89
#include "mirai/exported.h"
910

@@ -29,13 +30,19 @@ namespace Cyan
2930
{
3031
return !operator==(a);
3132
}
33+
34+
bool operator<(const UID_t& a) const
35+
{
36+
return data_ < a.data_;
37+
}
38+
3239
virtual ~UID_t() = default;
3340
protected:
3441
explicit UID_t(int64_t id) : data_(id) {}
3542
virtual void __avoiding_object_slicing() const = 0;
3643
int64_t data_;
3744
};
38-
45+
3946
// 储存 QQ 号码的类型
4047
class QQ_t : public UID_t
4148
{
@@ -145,4 +152,26 @@ namespace Cyan
145152

146153
}
147154

155+
namespace std
156+
{
157+
template<> struct hash<Cyan::UID_t>
158+
{
159+
size_t operator() (const Cyan::UID_t& t) const {
160+
return size_t(t.ToInt64());
161+
}
162+
};
163+
template<> struct hash<Cyan::GID_t>
164+
{
165+
size_t operator() (const Cyan::GID_t& t) const {
166+
return size_t(t.ToInt64());
167+
}
168+
};
169+
template<> struct hash<Cyan::QQ_t>
170+
{
171+
size_t operator() (const Cyan::QQ_t& t) const {
172+
return size_t(t.ToInt64());
173+
}
174+
};
175+
}
176+
148177
#endif // !mirai_cpp_defs_qq_types_hpp_H_

include/mirai/mirai_bot.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace Cyan
6767
string GetMiraiCppVersion() const
6868
{
6969
// mirai-api-http v1.6.5
70-
return "1.10.0";
70+
return "1.11.0";
7171
}
7272

7373
/**

0 commit comments

Comments
 (0)