I'm trying to make a client list for a UDP Server.
#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);
}
}
I get the following error:
C2678 binary '<': no operator found which takes a left-hand operand of type 'const sockaddr_in'
I also tried using unordered_map which gives me the following error:
C2280 'std::hash<_Kty>::hash(const std::hash<_Kty> &)' :attempting to reference a deleted function
It compiles fine when I only declare the map. I can't seem to figure out what's wrong since sockaddr_in is defined by WinSock2. I'm using VS2017.