David Abrahams wrote:
Well, there's a default implementation that works for anything providing begin, so I suppose it doesn't need to be part of the concept from that point of view. However, some sequences might provide a more efficient one, and generic code that wants to use front should be able to count on it. More efficient than constant time? If 'begin' is required to have constant time, and 'deref' is constant time (deref is not documented to be constant time, but I assume it is - is this assumtion wrong?), and front can be implemented using begin and deref, then front is also constant time. Can any sequence beat it? Sure, with a smaller constant. one instantiation instead of two or more, for example. But in such cases the meta-function that should specialized/optimized is 'begin', not 'front', isn't it?
No. The default version of front always takes at least two instantiations (begin<...> and deref<...>). If you can do front in one instantiation and you want the optimization, you'd better specialize it.
If this single instantiation you save is important (which sounds to me like too small a thing to mess with, but if you claim otherwise, I'll take your word for it), then wouldn't you want to specialize 'back' as well as 'front', if possible? You might be able save an instantiation there as well... Moreover, if this single instantiation saving is important, should it be specialized for *all* sequences, including those already present in mpl?
When I said "there's no first element", I meant "there's no meaning to the term 'first element', which is *different* from the meaning of 'deref< begin< > >'".
I think the placement of a comma above and other subtleties make that not say what you mean. Do you mean,
The meaning of the term 'first element' is not distinct from that of 'deref< begin< > >'
?
If so, I have no argument with it.
Yes, that's what I meant. That comma probably was misplaced, as it managed to confuse even me trying to read my own text again... :-)