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
с std :: map не Compill. Только const_cast on & entity as a as auto iter = mymap.find (const_cast (& entity));
делает это компиляция.>
Вот небольшой кусочек кода: < /p> [code]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 [/code] с std :: map не Compill. Только const_cast on & entity as a as auto iter = mymap.find (const_cast (& entity)); делает это компиляция.>