|
Boost : |
Subject: Re: [boost] AlRangeExandrescu?
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-07-27 14:26:06
Steven Watanabe wrote:
> Stewart, Robert wrote:
> > You said all ranges can be expressed as a pair of iterators. I
> > claimed some ranges don't have a predetermined end, so can't be
> > expressed as a pair of iterators. Dave Abrahams correctly noted
> > that it is possible to make an iterator that takes a predicate
> > and, I infer, becomes the end iterator once the range indicated
> > by the predicate has been traversed. Reversing said iterator
> > might be a bit harder.
> >
> > How about another try: traversing a range with changing criteria?
> > A particular range class can take a predicate or some other
> > traversal influencing argument that can change with each
> > advance. How would you express that with iterator pairs?
>
> Easily. First of all, consider what's possible if the two iterators
> are allowed to be different types. Then all the actual state can
> be put in the first iterator and comparison to the second iterator
> can just check whether the range is empty. Once you have that,
> you can use boost::variant to store both iterators as the same type.
> This will not be efficient, but it will work.
That may well work, but the range version would certainly be more straightforward and, as you noted, efficient. Of course, once you permit the iterators to have different types, you also increase the opportunity for mixing them incorrectly, which won't happen with an Alexandrescu range.
_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk