In the below example, I'd like to delete just t and keep rest of the values associated with id.
std::map<int,map<int,Object&>> rootSet;
rootSet.erase(id,t);
The erase function cannot do this. You would have to do this yourself by grabbing a reference to the inner map, and calling erase on it.
std::map<int,std::map<int,Object&>> rootSet;
auto _where = rootSet.find(id);
if ( _where != rootSet.end() ) {
_where->second.erase( t );
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.