Changes in src/GenPoly/ScopedMap.h [0531b5d:933667d]
- File:
-
- 1 edited
-
src/GenPoly/ScopedMap.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ScopedMap.h
r0531b5d r933667d 17 17 #define _SCOPEDMAP_H 18 18 19 #include <cassert>20 19 #include <iterator> 21 20 #include <map> … … 165 164 void endScope() { 166 165 scopes.pop_back(); 167 assert( ! scopes.empty() );168 166 } 169 167 … … 190 188 return end(); 191 189 } 192 const_iterator find( const Key &key ) const { 193 return const_iterator( const_cast< ScopedMap< Key, Value >* >(this)->find( key ) ); 194 } 190 const_iterator find( const Key &key ) const { return const_iterator( find( key ) ); } 195 191 196 192 /// Finds the given key in the outermost scope inside the given scope where it occurs … … 204 200 return end(); 205 201 } 206 const_iterator findNext( const_iterator &it, const Key &key ) const { 207 return const_iterator( const_cast< ScopedMap< Key, Value >* >(this)->findNext( it, key ) ); 208 } 202 const_iterator findNext( const_iterator &it, const Key &key ) const { return const_iterator( findNext( it, key ) ); } 209 203 210 204 /// Inserts the given key-value pair into the outermost scope … … 214 208 } 215 209 std::pair< iterator, bool > insert( const Key &key, const Value &value ) { return insert( std::make_pair( key, value ) ); } 216 217 Value& operator[] ( const Key &key ) { 218 iterator slot = find( key ); 219 if ( slot != end() ) return slot->second; 220 return insert( key, Value() ).first->second; 221 } 210 222 211 }; 223 212 } // namespace GenPoly
Note:
See TracChangeset
for help on using the changeset viewer.