
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?
What is it good for? Isn't it obvious? Getting the first element of the sequence. But there is no 'first element' in Associative Sequences. From the Associative Sequence doc:
"Unlike associative containers in the C++ Standard Library, MPL associative sequences have no associated ordering relation"
Come on, man, use common sense. That doesn't mean there's no first element. That just means there's no guarantee which of the elements it will turn out to be. If it's a set, for example, you can look at front, then iterate over [next
::type, end<S>::type) and never encounter that value again.
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< > >'". My point was that if the meaning is the same, there's no need for it (unless we're talking about options for performance gain, which is what we talked about in the previous paragraph), and a different meaning just doesn't exist.
Providing 'front' without 'back' sounds stridently asymmetric to me. See any singly-linked list implementation. Singly-linked containers were excluded from the standard library, and probably for a good reason,
Yeah, the committee only had so much time to process what Alex gave them.
I never found myself wishing I had a singly-linked-list. Maybe I just don't have enough experience...
so I don't see why they should be re-introduced in MPL.
Um, it's a little late for that. Type lists (mpl::list) are one of the most basic kinds of type sequences.
And what is mpl::list good for? I tried to find an answer to this in the docs, but found nothing.