Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2008-07-07 19:11:52


Steven Watanabe wrote:
> AMDG
>
> oliver wrote:
>> what i really wanna do is not to name the objects i put i the fusion
>> vector.
>> they should be constructed in place and only be accessed through the
>> fusion vector.
>> should look something like this:
>>
>> typedef boost::fusion::vector<JobA, JobB, JobC> tJobs;
>> struct System
>> {
>> System(Da& da) : fJobs(JobA(da), JobB(da, 2), JobC(da, 3))
>> {}
>> private:
>> tJobs fJobs;
>> };
>>
>
> This exact syntax cannot be implemented without a copy constructor.
> JobA(da) creates a temporary JobA which is then copied into the
> fusion::vector. You would have to use something like
>
> fJobs(boost::in_place(da), boost::in_place(da, 2), boost::in_place(da, 3))

Ok, thanks to other folks for reminding me of in_place_factory.
So, yes, in_place is indeed the solution here. I'm not sure though
when I can have the time to actually implement it, so first, I'll
ask the OP (Oliver Mueller) to add a trac ticket for this item.

In the meantime, I welcome contributions. Implementing this shouldn't
be too hard, but it involves modifying a couple of container classes
to take in the lazy factories. Hmmm... come to think of it, a lot
of fusion functions can also take advantage of it (push_back, etc.).

Any takers? ;-)

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk