Код: Выделить всё
class myClass {
public:
void myMethod() const {
for (const auto& entity : myList) {
auto iter = myMap.find(&entity);
}
}
private:
std::list myList;
std::unordered_map myMap;
};
< /code>
Метод mymethod () < /code> помечен const, поскольку он не должен изменять какой -либо член данных. not viable: 'this' argument has type 'const std::unordered_map', but method is not marked const
note: candidate template ignored: requirement '__is_transparent_v' was not satisfied [with _K2 = const int *]
note: candidate Шаблон игнорируется: требование '__is_transparent_v ' не было удовлетворено [с _k2 = const int *]
Изменение std :: unomordered_map делает это компиляция.>
Подробнее здесь: https://stackoverflow.com/questions/797 ... -compiling