I have the following compiler error, how could I fix it?
error: instantiated from `_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&a
You need a comparison function for the map
. You can either create operator<
that compares two instances of ar
, or you can create a custom function and pass it as the 3rd template parameter.
An example of the former might be:
class ar {
...
bool operator<(const ar& rhs) const {
return std::tie(a,b,c) < std::tie(rhs.a, rhs.b, rhs.c);
}
...
};