|
Boost : |
From: Stjepan Rajko (stipe_at_[hidden])
Date: 2008-07-15 03:49:21
Hello,
I recently ran into a need to initialize a fusion vector with a single
argument which is then used to construct all of the vector elements.
For example, something that would allow:
fusion::vector<int, float, double> ones(initialize_all_with(),1);
// at_c<0>(ones) == 1
// at_c<1>(ones) == 1.0f
// at_c<2>(ones) == 1.0;
I hacked fusion::vector so that the above works. Is this addition of
interest to anyone else?
There is another (perhaps more elegant) solution in implementing a new
fusion "array" Sequence (one where all element types are identical)
which can construct all elements from a single constructor argument,
and then using that sequence to do the above initialization. E.g.,
fusion::vector<int, float, double> ones(fusion::array<int, 3>(1));
... or (another solution) a make_array function that returns a fusion::vector:
fusion::vector<int, float, double> ones(fusion::make_array<3>(1));
It would be great if one of these solutions (or a different solution)
were added to fusion. I can take a stab at putting something together,
if any of them are acceptable. That is, unless this is already
possible in some way that I can't see at the moment :-)
Regards,
Stjepan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk