+typedef std::list<std::shared_ptr<objfile>> objfile_list;
+
+/* An iterator that wraps an iterator over std::shared_ptr<objfile>,
+ and dereferences the returned object. This is useful for iterating
+ over a list of shared pointers and returning raw pointers -- which
+ helped avoid touching a lot of code when changing how objfiles are
+ managed. */
+
+class unwrapping_objfile_iterator
+{
+public:
+
+ typedef unwrapping_objfile_iterator self_type;
+ typedef typename ::objfile *value_type;
+ typedef typename ::objfile &reference;
+ typedef typename ::objfile **pointer;
+ typedef typename objfile_list::iterator::iterator_category iterator_category;
+ typedef typename objfile_list::iterator::difference_type difference_type;
+
+ unwrapping_objfile_iterator (const objfile_list::iterator &iter)
+ : m_iter (iter)
+ {
+ }
+
+ objfile *operator* () const
+ {
+ return m_iter->get ();
+ }
+
+ unwrapping_objfile_iterator operator++ ()
+ {
+ ++m_iter;
+ return *this;
+ }
+
+ bool operator!= (const unwrapping_objfile_iterator &other) const
+ {
+ return m_iter != other.m_iter;
+ }
+
+private:
+
+ /* The underlying iterator. */
+ objfile_list::iterator m_iter;
+};
+
+
+/* A range that returns unwrapping_objfile_iterators. */
+
+struct unwrapping_objfile_range
+{
+ typedef unwrapping_objfile_iterator iterator;
+
+ unwrapping_objfile_range (objfile_list &ol)
+ : m_list (ol)
+ {
+ }
+
+ iterator begin () const
+ {
+ return iterator (m_list.begin ());
+ }
+
+ iterator end () const
+ {
+ return iterator (m_list.end ());
+ }
+
+private:
+
+ objfile_list &m_list;
+};
+