C++ 标准:映射C2678二进制'<';:未找到接受类型为';的左操作数的运算符;const sockaddr_in';

C++ 标准:映射C2678二进制'<';:未找到接受类型为';的左操作数的运算符;const sockaddr_in';,c++,dictionary,C++,Dictionary,我正在尝试为UDP服务器创建客户端列表 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include "stdafx.h" #include <map> #include <unordered_map> #include <WS2tcpip.h> #include <WinSock2.h> #include <Windows.h> #pragma co

我正在尝试为UDP服务器创建客户端列表

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include "stdafx.h"
#include <map>
#include <unordered_map>
#include <WS2tcpip.h>
#include <WinSock2.h>
#include <Windows.h>

#pragma comment(lib, "Ws2_32.lib")


std::map<sockaddr_in, int> clientList;

....
void Listen(){
    sockaddr_in client;
    [...]
    if (clientList.find(client) == clientList.end()) {
        printf("Got a new client!\n");
        std::pair<sockaddr_in, uint64_t> item(client, rand());
        clientList.insert(item);
    }
}
\ifndef WIN32\u LEAN\u和\u MEAN
#定义WIN32_精益_和_平均值
#恩迪夫
#包括“stdafx.h”
#包括
#包括
#包括
#包括
#包括
#pragma注释(lib,“Ws2_32.lib”)
地图客户端列表;
....
void Listen(){
客户端中的sockaddr_;
[...]
if(clientList.find(client)=clientList.end()){
printf(“获得新客户!\n”);
std::配对项(客户端,rand());
客户列表。插入(项目);
}
}
我得到以下错误:

C2678 binary '<': no operator found which takes a left-hand operand of type 'const sockaddr_in'
C2280 'std::hash<_Kty>::hash(const std::hash<_Kty> &)' :attempting to reference a deleted function

C2678 binary'可能是,这有助于映射需要一个比较函数,因为它是一个二进制搜索树,而无序映射需要has表的哈希函数。要将
sockaddr_in
用作
std::map
键,需要重载
运算符