Re: [Boost-users] [fusion] subset view
I would like to make a subset view of the element in a tuple. It would, for example, give me a view into the first, third, and fifth element of the tuple. It isn't clear how to do this with the available views.
You could do the following (untested): * Use zip to zip an mpl range of numeric indexes to your sequence * Use filter to extract the positions you want, based on the indices zipped on above * Use transform to remove the position labels so the sequence elements are just your desired data. The above works only if you need const access, as the algorithms return views to const data. If you need non-const data, you can use the corresponding views. The above is somewhat awkward, if there is some criteria other than position index that can be used to extract your elements, you may be able to do a lot better. Or you could choose different data structures to start off with, for example if you really have 2 subsets of elements, sub0 and sub1, and you know they're separate, store them in 2 fusion containers, and when you need to work on the whole, use fusion::join to glue them together. HTH Cheers Dan ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/
On 10/18/07, dan marsden
I would like to make a subset view of the element in a tuple. It would, for example, give me a view into the first, third, and fifth element of the tuple. It isn't clear how to do this with the available views.
You could do the following (untested): * Use zip to zip an mpl range of numeric indexes to your sequence * Use filter to extract the positions you want, based on the indices zipped on above * Use transform to remove the position labels so the sequence elements are just your desired data.
The above works only if you need const access, as the algorithms return views to const data. If you need non-const data, you can use the corresponding views.
HTH
Cheers
Dan
I figured something like what you proposed was necessary, but I was hoping there might be a short cut. Thanks, Chris
participants (2)
-
Chris Weed
-
dan marsden