Boost logo

Boost :

From: oliver (oliver.mueller_at_[hidden])
Date: 2008-07-07 10:30:18


Joel de Guzman <joel <at> boost-consulting.com> writes:

>
> Hmm... well...
> a) How do you put a noncopyable object in a container?
> b) How do you copy a container with noncopyable elements?
>

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;
};

there are several operations that need to include all jobs - non has to be
left out - and to avoid repetitive coding, it would be nicer to only operate
on fJobs.

> Fusion vector is based on stl vector. Even stl vector requires copy
> constructible types.
>
> One possibility is to store your object in a smart pointer or
> wrap it in a reference wrapper. Then, the smart pointer and
> reference wrapper can be stored in the fusion container.
>
but doesn't it make a difference that the stl sequences are
runtime-extensible?
you always get an empty sequence and add to it at runtime.
with fusion::vector, i know exactly in advance how many objects i need to
create (i mean at compile time), and i have to explicitly call
the constructor in the
initialization list. from this point of view i thought it rather
behaves like the initialization of an array.


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