Subject: Re: [boost] [iterators] Proof-of-concept for a sentinel iterator adapter
From: Beman Dawes (bdawes_at_[hidden])
Date: 2009-05-13 17:06:03
On Wed, May 13, 2009 at 12:38 PM, Simonson, Lucanus J
> Thorsten Ottosen wrote:
>> joaquin_at_[hidden] skrev:
>>> Beman Dawes escribió:
>>>> Attached is proof-of-concept code for a sentinel iterator adapter.
>>>> It turns a pointer to sentinel terminated sequence, such as a
>>>> C-style string, into a forward iterator with a conforming end
>>> Having Sentinel specified as a non-type template parameter greatly
>>> reduces the category of types this can work with. I'd replace it
>>> with some SentinelFactory policy or something.
>> That is not a bad idea, although it would really be good if
>> the basic case can stay as optimaized as currently
>> (having a static member). I guess having a static member is
>> not an option for a general policy, thus giving us the usual
>> iterator problem of double storage.
> I don't understand the rationale for m_sentinel. Couldn't the code refer to Sentinel directly as a compile time constant as opposed to a static member variable?
The concern is that Sentinel() isn't a compile time constant. It is a
potentially expensive call to a constructor. An optimizer may be smart
enough to resolve Sentinel() at compile time, and generate maximally
efficient code accordingly, but there is no guarantee of that.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk