/** ** \file misc/scoped-map.hh ** \brief Declaration of misc::scoped_map. ** ** This implements a stack of dictionnaries. Each time a scope is ** opened, a new dictionnary is added on the top of the stack; the ** dictionary is removed when the scope is closed. Lookup of keys ** is done in the last added dictionnary first (LIFO). ** ** In particular this class is used to implement symbol tables. **/ #pragma once #include #include #include #include namespace misc { template class scoped_map { // FIXME DONE: Some code was deleted here. public: // initializes a new stack with an empty map on top as the first scope scoped_map() { scopes_.push_back(std::map()); } void put(const Key& key, const Data& value); Data get(const Key& key) const requires(!std::is_pointer_v); Data get(const Key& key) const requires(std::is_pointer_v); std::ostream& dump(std::ostream& ostr) const; void scope_begin(); void scope_end(); private: std::vector> scopes_; }; template std::ostream& operator<<(std::ostream& ostr, const scoped_map& tbl); // FIXME DONE: Some code was deleted here. // heehee } // namespace misc #include