Boost logo

Boost :

From: nbecker_at_[hidden]
Date: 2002-01-29 11:35:32


>>>>> "David" == David Abrahams <david.abrahams_at_[hidden]> writes:

    David> ----- Original Message -----
    David> From: <nbecker_at_[hidden]>

>> I was hoping to find a simpler example. One thing not clear to me is
>> the first template parameter T. It says "operand type". In the
>> example, it is set to "test_iter<T,R,P>", which is a self-reference.
>> I'm confused.

    David> The iterator helpers use the same idiom as the rest of the operators library
    David> templates: the first parameter is the type to which you are adding the
    David> operator functionality, i.e. the derived class. Don't worry; it's correct
    David> and it works.

    David> FWIW, most people find the iterator helpers aren't that useful
    David> now that we
    David> have the iterator adaptor library. It does a lot more to
    David> automate the job of
    David> making correct and useful iterators.
>>
>> I'll have a look. I thought the adaptors were, well, adaptors. In
>> this case, I'm not adapting an existing iterator, but making a new
>> one, so I didn't think that the adaptors were applicable.

    David> You can adapt anything; it doesn't have to be an iterator. Your iterator has
    David> some state data, right? Just adapt that.

Depends what you mean by "adapt". If by "adapt x" you mean "x is the
first parameter to iterator_adaptor", then I believe x has to be an
iterator. You can't directly adapt a container, for example. You can
adapt the container's iterator.

I guess if you want to adapt the container, you have to do it in 2
steps. First adapt the container's iterator, then make an object that
uses that adapted iterator.


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