Changeset 4612bb0 for src/Common


Ignore:
Timestamp:
Jul 9, 2018, 4:48:58 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
046959b
Parents:
c3e44e6a
Message:

Add push operations for ScopedMap? notes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/ScopedMap.h

    rc3e44e6a r4612bb0  
    3333        struct Scope {
    3434                MapType map;
    35                 Note note;     
     35                Note note;
     36
     37                template<typename N>
     38                Scope(N&& n) : map(), note(std::forward<N>(n)) {}
     39               
     40                Scope() = default;
     41                Scope(const Scope&) = default;
     42                Scope(Scope&&) = default;
     43                Scope& operator= (const Scope&) = default;
     44                Scope& operator= (Scope&&) = default;
    3645        };
    3746        typedef std::vector< Scope > ScopeList;
     
    210219        }
    211220
     221        // Starts a new scope with the given note
     222        template<typename N>
     223        void beginScope( N&& n ) {
     224                scopes.emplace_back( std::forward<N>(n) );
     225        }
     226
    212227        /// Ends a scope; invalidates any iterators pointing to elements of that scope
    213228        void endScope() {
     
    217232
    218233        /// Default constructor initializes with one scope
    219         ScopedMap() { beginScope(); }
     234        ScopedMap() : scopes() { beginScope(); }
     235
     236        /// Constructs with a given note on the outermost scope
     237        template<typename N>
     238        ScopedMap( N&& n ) : scopes() { beginScope(std::forward<N>(n)); }
    220239
    221240        iterator begin() { return iterator(scopes, scopes.back().map.begin(), currentScope()).next_valid(); }
Note: See TracChangeset for help on using the changeset viewer.