This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ edge_iterator (was: Re: [SH] PR 53976 - Add RTL pass to eliminate clrt, sett insns)


On Sat, 2013-12-14 at 10:19 +0100, Richard Biener wrote:
> Oleg Endo <oleg.endo@t-online.de> wrote:
> >On Thu, 2013-12-12 at 03:13 -0500, Trevor Saunders wrote:
> >> On Wed, Dec 11, 2013 at 06:47:37PM +0100, Oleg Endo wrote:
> >> > On Thu, 2013-11-21 at 00:04 +0100, Steven Bosscher wrote:
> >> > > Declaring the edge_iterator inside the for() is not a good
> >argument
> >> > > against FOR_EACH_EDGE. Of course, brownie points are up for grabs
> >for
> >> > > the brave soul daring enough to make edge iterators be proper C++
> >> > > iterators... ;-)
> >> 
> >> so, as a first question why do we have a special edge iterator at
> >all? it
> >> seems like we could just have a vec iterator and use that removing a
> >> bunch of indirection that seems pretty useless.
> >
> >I don't know why it's there.  Looks like a remainder from the pre-C++
> >code, as the conversion is being done step by step.
> 
> The fact that we iterate over a vector is an implementation detail that should be hidden.

Yep.  Actually there are two implementation details:

> The fact that we iterate over a vector
                1) ^^^^^^^     2) ^^^^^^

This is addressed in the STL by splitting iterators and algorithms.
Whether a specialized/optimized version of an algorithm is available
when used with a particular iterator type (or inherently container type)
becomes an implementation detail and does require changes to code that
uses algorithms or iterators.

Cheers,
Oleg


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]