[fusion] Non-default initialisation of sequence components.
Hi Everyone, I'm wondering if there is a (built-in) way in boost::fusion to instantiate a sequence of heterogeneous elements while passing an identical set of arguments to the constructor of each element? It seems like the only options are to default construct the elements or to supply references to previously constructed elements. As a semi-concrete example, is there a way to achieve the equivalent of the following? template <int Label> struct TestType { TestType(int i, double d, string s):I(i), D(d), S(s){} int I; double D; string S; }; int main(int argc, char* argv[]){ typedef vector<int, double, string> ArgVector; typedef vector<Type<1>, Type<2>, Type<3> > TypeVector; ArgVector args(1, 2.5, "hello"); // Want to pass the elements of Args as constructor arguments to each element of vec. TypeVector vec(args); } Any help much appreciated, Hugh
AMDG Hugh Dickinson wrote:
I'm wondering if there is a (built-in) way in boost::fusion to instantiate a sequence of heterogeneous elements while passing an identical set of arguments to the constructor of each element? It seems like the only options are to default construct the elements or to supply references to previously constructed elements.
I believe that there's a trac ticket for allowing the use of boost::in_place_factory with fusion. As far as I know, this isn't implemented yet, though. In Christ, Steven Watanabe
participants (2)
-
Hugh Dickinson
-
Steven Watanabe