Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2008-07-07 09:22:47

Oliver Mueller wrote:
> hello,
> at the last boostcon i had the chance to be introduced to fusion by
> dan and joel. i appreciate the idea of fusion a lot and the library
> amazingly detailed. since we have already had great exposure to the
> mpl the fusion concepts present ample opportunity for new ideas.
> still, some little things sometimes make it hard for me to keep
> rolling with fusion:
> i need to have a vector/list of non-copy-constructible types. using
> e.g. a standard fusion::vector that does not seem to be possible since
> objects are constructed first, then copied. of course, i could provide
> a public copy-constructor but that would in other places remove the
> compiler enforced contract that those objects are not copied under any
> circumstances.
> i also cannot think of a good reason why it is nesseccary to copy in that case.
> so is there a way of having a fusion sequence that does work on
> non-copy-constructible types?

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

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.


Joel de Guzman

Boost list run by bdawes at, gregod at, cpdaniel at, john at