Remove element from std::map based on the time of insertion
问题 I need to erase elements from an std::map based on the time of insertion (or something else more efficient than that). The map will probably hold thousands of elements and if I store the time and iterate the map to check each elements time, it will probably end up being quite time consuming. Does anyone have any good idea how to erase elements from a std::map when they are getting old? 回答1: The std::map<> type has no notion of when an element was inserted. It only serves to hold a key / value