Boost logo

Boost :

Subject: Re: [boost] [iterators] Proof-of-concept for a sentinel iterator adapter
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-05-13 13:06:53


AMDG

Simonson, Lucanus J wrote:
> Steven Watanabe wrote:
>
>> What about using a function object for testing for the sentinal
>> and using EBO to optimize it away if it is stateless?
>>
>
> Is your suggestion the same as the code I just posted?

It's a different syntax but the effect is the same

> If not could you post what you had in mind and explain what you mean about EBO for those of us who aren't up to speed on that issue?
>

template<class T, class Sentinel>
class sentinel_iterator {
public:
    sentinel_iterator(T* ptr, Sentinel s = Sentinel());
    sentinel_iterator& operator++() {
        ++data.first();
        if(data.second()(*data.first())) data.first() = 0;
    }
    //...
private:
    boost::compressed_pair<T*, Sentinel> data;
};

> By the way, can you spot anything wrong with the code I posted. The fact that it passes Beman's unit tests gives me some confidence, but I'm not completely convinced that it can really be so simple.
>

It looks okay to me...

In Christ,
Steven Watanabe


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