STD :: Under Ordered_map Data Mitglied mit const -Schlüssel innerhalb der const -Methode, die nicht kompiliert werden

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: STD :: Under Ordered_map Data Mitglied mit const -Schlüssel innerhalb der const -Methode, die nicht kompiliert werden

by Anonymous » 18 Aug 2025, 12:44

Hier ist ein kleines Stück Code: < /p>

Code: Select all

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>
Die Methode myMethod () < /code> wird konstant gekennzeichnet, da sie kein Datenelement [url=viewtopic.php?t=12045]ändern[/url] sollte. Funktion nicht lebensfähig: 'Dieses' Argument hat Typ 'const Kandidatenvorlage ignoriert: Anforderung '__is_transparent_v ' war nicht erfüllt [mit _k2 = const int *]

Ändern der std :: uncordered_map 
mit einem std :: map

Top