Boost logo

Boost :

From: Geoffrey Irving (irving_at_[hidden])
Date: 2006-09-29 12:12:48


On Fri, Sep 29, 2006 at 11:58:48AM -0400, David Abrahams wrote:
> Joel de Guzman <joel_at_[hidden]> writes:
>
> > Here's another problem:
> >
> > std::map<int*, int*> m;
> >
> > generic code that treats pair<int* int*> as an iterator_range
> > will treat m's data type incorrectly.
>
> No, generic code doesn't look at types and say, "which of two concepts
> with no refinement relationship does this type fulfill?" and then take
> different actions based on the answer. The only such type-based
> dispatching in generic code comes through algorithm specialization:
> "this type fulfills concept X, but also concept Y which is a
> refinement of X, so I'll use that information to do whatever I was
> going to do more efficiently."

The problem here is that there is one concept, namely a runtime sequence,
that pair<int*,int*> fulfills in two unrelated ways. So generic code
does need to be able to decide which way to interpret it.

Or the concepts of iterator_range and runtime sequence have to be
separated, which is unfortunate, since iterator_range is a very natural
refinement of a runtime sequence.

Geoffrey


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