From: Roland McGrath Date: Fri, 2 Oct 2009 21:26:42 +0000 (-0700) Subject: c++/subr.hh (subr::stackish): New template type. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a9336afe5922be61e6ff2a195c66bcc2b8291ff;p=thirdparty%2Felfutils.git c++/subr.hh (subr::stackish): New template type. --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 019427d35..7e32927b6 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,7 @@ 2009-10-02 Roland McGrath + * c++/subr.hh (subr::stackish): New template type. + * c++/dwarf_comparator: Fix overload magic to distinguish reference comparisons from child comparisons. diff --git a/libdw/c++/subr.hh b/libdw/c++/subr.hh index c080aa8a4..d8daa80ff 100644 --- a/libdw/c++/subr.hh +++ b/libdw/c++/subr.hh @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1225,11 +1226,6 @@ namespace elfutils return *_m_head; } - inline const value_type &const_top () - { - return const_cast (this)->top (); - } - inline const value_type &const_top () const { return top (); @@ -1359,6 +1355,54 @@ namespace elfutils } }; + // Compatible with sharing_stack, but actually a std::stack. + template > + struct stackish + : public std::stack + { + inline const T &const_top () const + { + return this->top (); + } + + inline void clear () + { + this->c.clear (); + } + + typedef typename container_type::const_reverse_iterator + const_reverse_iterator; + + inline const_reverse_iterator rbegin () const + { + return this->c.rbegin (); + } + + inline const_reverse_iterator rend () const + { + return this->c.rend (); + } + + template + inline bool + equal (const stackish &other, + pred_type &pred, typename container_type::size_type skip = 0) const + { + if (other.size () != this->size ()) + return false; + + typename container_type::const_reverse_iterator a = this->rbegin (); + typename other_container_type::const_reverse_iterator b + = other.rbegin (); + + std::advance (a, skip); + std::advance (b, skip); + + return std::equal (a, this->rend (), b, pred); + } + }; + /* This is a dummy you can template/syntactically use in place of std::cout et al for disabled debugging spew. */ struct nostream