Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] more trouble with transform
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2011-11-12 07:19:54


On Sat, Nov 12, 2011 at 1:08 PM, Gennadiy Rozental <rogeeff_at_[hidden]>wrote:

> Ovanes Markarian <om_boost <at> keywallet.com> writes:
>
> > You need to make a list of references to Bs:
> > B b1, b2;
> > auto z1 = fusion::make_list( ref(b1), ref(b2) );
> > auto z2 = fusion::as_list( fusion::transform( z1, make_c() ) );
>
> This one indeed works, but what I am really after is something like this:
>
> auto z1 = fusion::make_list( B(), B() );
> auto z2 = fusion::as_list( fusion::transform( z1, make_c() ) );
>
> I know first line will move constructed instances into list z1. Next I
> need to
> mutate them and adding boost::ref around B() is impossible. In reality my
> use
> case somewhat more complicated. Something like this:

Quickly, I can come up with: Declare the mutating member inside B
(B::make_c()) as const and declare mutated members with mutable. This will
work as well. Than you don't need to pass B by ref. You can than make it as
you stated.

May be there is a more elegant solution, I will think about it.

Best Regards,
Ovanes



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net