Ignore:
Timestamp:
Feb 3, 2023, 4:04:22 PM (15 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
35d1de5
Parents:
e9b5043
Message:

Replaced ScopedMap::erase with a version that should avoid the order of declaration problems and also better reflects how it is actually used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/ScopedMap.h

    re9b5043 r21a2a7d  
    167167        }
    168168
    169         iterator erase( iterator pos );
     169        /// Erases element with key in the innermost scope that has it.
     170        size_type erase( const Key & key ) {
     171                for ( auto it = scopes.rbegin() ; it != scopes.rend() ; ++it ) {
     172                        if ( size_type i = it->map.erase( key ) ; 0 != i ) return i;
     173                }
     174                return 0;
     175        }
    170176
    171177        size_type count( const Key & key ) const {
     
    345351};
    346352
    347 template<typename Key, typename Value, typename Note>
    348 typename ScopedMap<Key, Value, Note>::iterator
    349                 ScopedMap<Key, Value, Note>::erase( iterator pos ) {
    350         MapType & scope = (*pos.scopes)[ pos.level ].map;
    351         const typename iterator::wrapped_iterator & new_it = scope.erase( pos.it );
    352         iterator it( *pos.scopes, new_it, pos.level );
    353         return it.next_valid();
    354 }
    355 
    356353// Local Variables: //
    357354// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.