
David Abrahams wrote:
Joel de Guzman <joel@boost-consulting.com> writes:
* Boost.Range and Boost.Fusion both interpret an int*[4] as a sequence of 4 values of type int*. Consistent
* Boost.Fusion interprets a pair<int*,int*> as a sequence of two values of type int*.
* Boost.Range interprets a pair<int*,int*> x as a sequence of x.second-x.first values of type int. Oh man, Now I see the problem. Pardon my slowness!!! Well, it seems, this interpretation of Boost.Range for pair<T*,T*> (or in general, std::pair<iterator,iterator> is at the very least suspicious. If we all agree that pair<T,T> is a tuple (a sequence in Fusion's sense), then pair<T*,T*> shouldn't be any different. I'd say that treating std::pair<iterator,iterator> as a runtime sequence is the wrong generalization.
I disagree. There's no "wrong" here. It's going to be very common that in two different well-designed generic libraries, one 3rd party type plays different two different roles.
In my honest opinion... Pairs, triples, quadruples etc. are tuples. Other interpretations of that generalization, IMO, are bogus -- especially one that gives special meaning to pair<iterator,iterator> as a runtime sequence. A pair<iterator,iterator> and an iterator_range<iterator> are different beasts. The first is a tuple comprising 2 iterator elements and the other is an, ehmm, an iterator range. Making them behave similarly, confuses pair's intended meaning and leads to conceptual problems such as the one you posed. 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. To me it's like, generalizing that something with a wing, a propeller, and all things that comprise an airplane-- is an airplane. No, not necessarily. The presence of these elements do not complete the picture. It can be, say, *just a collection of parts*. Hence, pair<iterator,iterator> is just a collection of 2 iterators, nothing more. All that being said, I don't care too much either way. It's not a concern of Fusion, AFAICT. Unless, you are asking for std::pair to be removed from the list of supported Fusion sequences? Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net