Boost logo

Boost Users :

From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2007-01-16 04:23:31


Joel de Guzman wrote:
> Yuval Ronen wrote:
>> If I have a
>>
>> typedef fusion::tuple<X, Y, Z> T;
>>
>> can I somehow create a T instance like
>>
>> T t(1, "hello");
>>
>> and by that I mean that each of T's elements (of types X, Y and Z) would
>> be constructed using the constructor that accepts an int and a string,
>> assuming there is such a constructor for all T's elements. If there
>> isn't such constructor for all T's elements, then it shouldn't compile,
>> of course.
>
> No.
>
>> Of course using the exact syntax above is not possible, because it's
>> reserved for something else, but any other syntax would be just as good
>> (perhaps using in_place_factory).
>
> Does it have to be done at construction? If not, you can use for_each.

Yes, I have to use the constructors. For performance reasons, and
especially because X, Y and Z don't have a default constructor.

> If yes, it might be interesting to have a forward fusion sequence that
> generates its elements on the fly (a generator). But this also presents
> some complications because you want the elements to be constructed
> with 2 arguments.

I want the ability to have the elements be constructed with any number
of arguments. Two is just in this specific case...

> So, I have no immediate ideas for you. If you have
> some specific suggestions, I'm all ears.

I don't have any ideas, except maybe somehow use
boost::in_place_factory, but that's as specific as I can get... I do
think, though, that it's a valuable feature for fusion, for types that
don't have default constructors, or are non-copyable.

Yuval


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