Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-06-29 15:45:17


Geoff Wedig <wedig_at_[hidden]> writes:

> I have a question I'm hoping someone can answer. I've recently started
> using the iterator_facade class, and it's very useful, but it seems
> inefficient in some respects. Specifically, the < operator. According
> to the website docs, this uses the distance_to() function defined by the
> derived class. That works fine for some iterators, but not others.
> Often, it's possible to have much more efficient operations than that.
> Take for example, some data structure of sorted strings. It is not
> necessary to know how many elements are between two strings to know
> whether one is before the other. Like 'use empty() rather than size()
> == 0' in Meyer's _Effective STL_, it would seem that a more efficient
> solution can be created in many cases.
>
> So, is there a way to do this, to override iterator_facade's system, or
> am I missing something?

Sure, just add your own operators that match better than the generic
ones provided by the library.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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