Given an mpl::vector of keys, and a fusion::vector of values, what's the easiest way to create a fusion::map? The obvious solution of just zipping the two sequences and passing the result to fusion::as_map doesn't work because as_map (somewhat narrowly) requires all elements to be fusion::pair, and Fusion's zip algorithm produces sequences of vector2. I'd like to see this generalized so that (a) as_map only requires sequences of 2-tuples and (b) fusion::pair meets the requirements for 2-tuples. -- Eric Niebler BoostPro Computing http://www.boostpro.com
On 11/2/2010 12:22 PM, Eric Niebler wrote:
Given an mpl::vector of keys, and a fusion::vector of values, what's the easiest way to create a fusion::map?
The obvious solution of just zipping the two sequences and passing the result to fusion::as_map doesn't work because as_map (somewhat narrowly) requires all elements to be fusion::pair, and Fusion's zip algorithm produces sequences of vector2. I'd like to see this generalized so that (a) as_map only requires sequences of 2-tuples and (b) fusion::pair meets the requirements for 2-tuples.
Makes perfect sense. Do you have a patch? Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
On 11/2/2010 8:23 AM, Joel de Guzman wrote:
On 11/2/2010 12:22 PM, Eric Niebler wrote:
Given an mpl::vector of keys, and a fusion::vector of values, what's the easiest way to create a fusion::map?
Nobody ever answered this one. It's ok, my immediate need has passed. I'm just curious if there's an easy way that I missed.
The obvious solution of just zipping the two sequences and passing the result to fusion::as_map doesn't work because as_map (somewhat narrowly) requires all elements to be fusion::pair, and Fusion's zip algorithm produces sequences of vector2. I'd like to see this generalized so that (a) as_map only requires sequences of 2-tuples and (b) fusion::pair meets the requirements for 2-tuples.
Makes perfect sense. Do you have a patch?
Sorry, no. I filed a feature request, instead. https://svn.boost.org/trac/boost/ticket/4830 -- Eric Niebler BoostPro Computing http://www.boostpro.com
On 11/10/2010 8:46 AM, Eric Niebler wrote:
On 11/2/2010 8:23 AM, Joel de Guzman wrote:
On 11/2/2010 12:22 PM, Eric Niebler wrote:
Given an mpl::vector of keys, and a fusion::vector of values, what's the easiest way to create a fusion::map?
Nobody ever answered this one. It's ok, my immediate need has passed. I'm just curious if there's an easy way that I missed.
The easy and obvious way is the one that you described below. It's a deficiency of Fusion that it's not doable this way as it should be. IOTW, there's no straightforward way ATM.
The obvious solution of just zipping the two sequences and passing the result to fusion::as_map doesn't work because as_map (somewhat narrowly) requires all elements to be fusion::pair, and Fusion's zip algorithm produces sequences of vector2. I'd like to see this generalized so that (a) as_map only requires sequences of 2-tuples and (b) fusion::pair meets the requirements for 2-tuples.
Makes perfect sense. Do you have a patch?
Sorry, no. I filed a feature request, instead.
Thanks, Eric. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
On Nov 2, 4:23 am, Joel de Guzman
On 11/2/2010 12:22 PM, Eric Niebler wrote:
Given an mpl::vector of keys, and a fusion::vector of values, what's the easiest way to create a fusion::map?
The obvious solution of just zipping the two sequences and passing the result to fusion::as_map doesn't work because as_map (somewhat narrowly) requires all elements to be fusion::pair, and Fusion's zip algorithm produces sequences of vector2. I'd like to see this generalized so that (a) as_map only requires sequences of 2-tuples and (b) fusion::pair meets the requirements for 2-tuples.
Makes perfect sense.
In my yesterday post I was asking for the opposite thing, to take a map and create two vectors, one of them with the value part of the pairs. I was expecting also an easy way to do this. Maybe some kind of "unzip" could be also naively expected from the library. Thank you, Alfredo
participants (3)
-
alfC
-
Eric Niebler
-
Joel de Guzman