Visiting an element of fusion sequence, selected at run-time

Here's a seemingly simple problem that I have spent most of my
Thanksgiving weekend on, and still don't have enough to boast:
Given:
1. A Boost.Fusion-compatible sequence;
2. An integral value i computed at runtime, known to be within
0..size(sequence);
implement an algorithm applying some sort of a generic visitor to the
i-th element of the sequence.
However long I looked through the documentation, I didn't find a ready
solution. Here's the best I was able to come up with on my own:
======================================================================
struct at_v {
template

On Mon, Nov 29, 2010 at 12:53 AM, Max Motovilov
Here's a seemingly simple problem that I have spent most of my Thanksgiving weekend on, and still don't have enough to boast:
Given:
1. A Boost.Fusion-compatible sequence; 2. An integral value i computed at runtime, known to be within 0..size(sequence);
Weird, this is the second time I've recommended the following in a week -- the easiest way to do what you want is with Steven Watanabe's switch utility. It was up for review a couple years ago and was accepted pending some changes but I don't think it was ever updated Documentation: http://dancinghacker.com/switch/ and you can get it from the Boost vault here: http://tinyurl.com/23qn7w -- -Matt Calabrese

Weird, this is the second time I've recommended the following in a week -- the easiest way to do what you want is with Steven Watanabe's switch utility. It was up for review a couple years ago and was accepted pending some changes but I don't think it was ever updated
Documentation: http://dancinghacker.com/switch/ and you can get it from the Boost vault here: http://tinyurl.com/23qn7w
-- -Matt Calabrese
Matt: Thanks very much! I _KNEW_ there'd be an [almost] exact solution somewhere. Was looking at phoenix::switch_ and wondering why isn't there a version based on sequences :-) Regards, ...Max...
participants (2)
-
Matt Calabrese
-
Max Motovilov