Boost logo

Boost :

From: Andreas Huber (ahd6974-spamgroupstrap_at_[hidden])
Date: 2005-08-03 03:43:28


David Abrahams <dave <at> boost-consulting.com> writes:
[snip]
> > I need to modify that sequence internally.
>
> You don't mean that, exactly, since all metadata is immutable.

Right, I mean that I can't use e.g. push_front on some sequences.

> > If any sequence was allowed (including immutable ones), I would need
> > to copy that sequence into an mpl::list<> first.
>
> Why an mpl::list<>? What's special about that structurue? Why not
> mpl::vector?

The sequence just needs to support certain operations, e.g. push_front,
reverse, etc. So, mpl::vector<> should work too (I never checked).

> Are you sure you couldn't get away with using some views onto the
> original sequence?

I'm not. Views are something I probably need to try when I get the time to
make compilation time optimizations.

> > I suspect that the copying slows down compilation noticeably (I
> > never had the chance to make measurements, so this may well be FUD),
> > so I figured that requiring a list is the best way to give the user
> > the opportunity to keep compilation as fast as possible.
>
> It's not; a vector would be faster.

Ok, that's good to know.

> Or you could just require any
> front extensible sequence, in which case, maybe deque is what you
> need?

Don't know, I can't think of anything that would keep you from using deque or
vector. I guess it would be best to document the exact requirements and make
measurements so that I can tell the user which of the standard mpl sequences
are best.

> > Sure, I could make a copy only if the user doesn't pass an
> > mpl::list<> and document that in the interface but nobody has ever
> > made a request in this direction. I guess this is due to the fact
> > that pretty much everybody specifies the InnerInitial states inline:
> >
> > struct Y;
> > struct Z;
> > struct X : sc::simple_state< X, Machine, mpl::list< Y, Z > > {};
>
> Why mpl::list and not mpl::vector or mpl::deque?

See above. All of them should work.

> > That is, I can't really think of a real-world example where you would
> > want to use an algorithm to fill that list...
> >
> > Would you allow any mpl sequence anyway?
>
> I certainly wouldn't require a list. Whether to accept every possible
> sequence is another question. I'm sure there are many models of the
> concept you actually need from the user.

Agreed, an appropriate item is now on my to-do list.

Thanks & Regards,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap 
from the address shown in the header.

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