Christian Henning wrote:
Hi there, is it somehow possible to access a sequence element at runtime?
You sure can. The 'at' function yields an L-value.
Just image you're reading some name value pairs from file and you would like them to assign them to a fusion sequences.
You must know the number of pairs you expect in advance (at compile time) to use the built-in Sequences that come with Fusion. Almost philosophical stuff: We have some (still undocumented) weaker Sequence Concepts that would (theoretically - not that I could see that this use case would make a lot of sense) allow you to turn an STL container into a Fusion sequence. Note however that Fusion-style iteration is terminated at compile time, so the sequence would be infinite and thus only work if evaluated lazily until the last element in the STL container.
This way I don't know they order the values are supplied. Is that possible?
For example take the following code:
<code> Sidenote: You might get into trouble calling constructors in static aggregate initialization (construction of 'any' objects in your code) if your code is compiled into a shared library. You might know already... Given an 'any' with the appropriate type and a Fusion 'map', you have to iterate the map (hand-coded on top of Fusion iterators, if you want to stop once you found what you're looking for) and check for typeid(typename first<elem>::type) == an_any.type() The other (possibly more efficient) alternative is to use 'switch' & 'case' but that isn't very flexible, unless you can automatically generate a 'switch' cascade, see http://article.gmane.org/gmane.comp.lib.boost.devel/153870 for further reading. Regards, Tobias