0

I'm trying to make a list of unordered sets of coordinates, as main model for a game of life. As so, I am trying to make the following code work :

#include <unordered_set>
#include <list>

struct coords {int x; int y;};
std::list<std::unordered_set<coords>> data;

This code leads to many, many errors (Thanks C++....) like the ones that follow :

error: no match for call to ‘(const std::hash<coords>) (const coords&)’
error: ‘value’ is not a member of ‘std::__and_<std::__is_fast_hash<std::hash<coords> >, std::__detail::__is_noexcept_hash<coords, std::hash<coords> > >’
error: ‘value’ is not a member of ‘std::__not_<std::__and_<std::__is_fast_hash<std::hash<coords> >, std::__detail::__is_noexcept_hash<coords, std::hash<coords> > > >’

and so on, and so forth.

Where do these errors come from, and more importantly, how could I have figured that out by myself, as those errors look totally unreadable ?

Magix
  • 4,989
  • 7
  • 26
  • 50
  • How are you compiling your code? – hugos May 09 '17 at 22:27
  • 1
    Btw, you need not repeat the `struct` keyword in C++. – Baum mit Augen May 09 '17 at 22:28
  • using the following CMakeLists.txt : `set (CMAKE_CXX_STANDARD 11); project(GOL_controller CXX); add_library(GOL SHARED src/main.cpp);` – Magix May 09 '17 at 22:29
  • @BaummitAugen I know, it came here from me trying to solve the problem ^_^ thanks anyway – Magix May 09 '17 at 22:30
  • 1
    *"how could I have figured that out by myself, as those errors look totally unreadable?"* In this particular case, I googled *"c++ unordered_set of custom type"*. But I agree, many error messages in C++ are terrible, such as this one. That's one of the main motivations of the Concepts TS, in hopes of getting an error along the lines of "Type `coords` must be hashable" in the future. – Baum mit Augen May 09 '17 at 22:34
  • Wow, awesome TS ! hope it will get included in the next C++ version :3 – Magix May 09 '17 at 22:38
  • 1
    @Magix It won't be in C++17 unfortunately, as it turned out to be not good enough yet. The error messages were much more verbose and unclear than intended. They try to get an improved version into C++20, let's hope for the best. It turns out standardizing C++ is hard. :) – Baum mit Augen May 09 '17 at 22:43

0 Answers0