|
Boost : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2006-09-29 19:42:11
Peter Dimov wrote:
> 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.
>
> Sometimes it does. Consider serialization, or stream output. You could have
>
> if( type is a range )
>
> output sequence of values
>
> else
>
> output something else
>
> Treating pair<pointer, pointer> as a range creates an ambiguity here.
And potentially dangerous too. first and last might not be valid,
they may point to separate single elements (e.g. heap objects),
or arrays from different locations, or combinations thereof.
Regards,
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk