How to remove an item from a set in a map?

I have a problem removing an element from setinside mapcalled accesrightsByRank. Card keys differ ACCESRIGHT: owner, modify, readand none. Values mapare equal setwith accessory names with specific ACCESRIGHTs.

    map<ACCESSRIGHT, set<string>>::const_iterator i;
    set<string>::const_iterator j;

    for(i = this->accessrightsByRank.begin(); i != this->accessrightsByRank.end(); i++){
        for(j = (*i).second.begin(); j != (*i).second.end(); j++){
            if( (*j).compare(p_Username) == 0){
                i->second.erase(j);
            }
        }
    }

I thought it would i->secondprovide me setfrom which I can erase a user name that no longer has a specific one ACCESRIGHT, but it looks like I did something wrong. Can someone explain to me why this does not work, and how do I configure my code?

This is the error I get:

IntelliSense: "std::set<_Kty, _Pr, _Alloc>::erase [ _Kty=std::string, _Pr=std::less<std::string>, _Alloc=std::allocator<std::string>]" ( , )              : (std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::string>>>)              : const std::set<std::string, std::less<std::string>, std::allocator<std::string>>

+4
2

, const_iterator. , , . :

map<ACCESSRIGHT, set<string>>::const_iterator i;
set<string>::const_iterator j;

:

map<ACCESSRIGHT, set<string>>::iterator i;
set<string>::iterator j;

. , .

+3

,

  • . , iterator, const_iterator.
  • - , . std::set::erase() , , .
  • i->second , (*i).second.
  • this-> , , .

,

map<ACCESSRIGHT, set<string>>::iterator i;

for(i = accessrightsByRank.begin(); i != accessrightsByRank.end(); i++){
    i->second.erase(p_Username);
}
+3

All Articles