Boost logo

Boost :

Subject: Re: [boost] lifetime of ranges vs. iterators
From: Arno Schödl (aschoedl_at_[hidden])
Date: 2008-09-03 13:36:15


>>> > I'm not there yet, but I know enough about the problem now that I
>>> > wouldn't "buy" a partial solution.
>>
>>> Before I start playing around with the problem, is my throwing
>> increment_and_dereference optimization fair game? I believe I can't > do
>> without.
>>
>> Since dereference does not need to end-check, throwing increment() is
>> probably the basic building block. Fair game?
>
>Sorry, I really don't know what you're asking.

A basic multiple-filter loop is this:

filter_increment {
  for(;;) {
    ++i;
    if( empty() || predA( dereference() && predB( dereference ) && predC( dereference ) && predD( dereference ) ) break;
    // <--- towards base_range *** function stack *** towards outermost filter_iterator ---->
  }
}

If empty() evaluates to true, all pred* are skipped. This "skipping" in recursion needs exceptions. Exceptions are the only means C++ gives us to "jump" in a recursive environment. At least in Win32, exceptions are slow, probably too slow to be practical. I heard that table-based exceptions are much faster, but I have no practical experience.

Before spending time working on the problem you posed, I want to make sure than my solution does not get trashed because I use exceptions. If we want to avoid them, I would say that there is no way to get optimal performance with stacked iterators, and I would not even try.

Arno

--
Dr. Arno Schoedl · aschoedl_at_[hidden] 
Technical Director 
 
think-cell Software GmbH · Invalidenstr. 34 · 10115 Berlin, Germany 
http://www.think-cell.com · phone +49-30-666473-10 · toll-free (US) +1-800-891-8091
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Charlottenburg, HRB 85229

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk