From: Eric Friedman (ebf_at_[hidden])
Date: 2003-10-26 17:30:31
Jaap Suter wrote:
> I was wondering if it would be possible to provide a method for in-place
> construction into a Boost variant, to avoid copy construction.
> For example:
> boost::variant<foo, bar> v;
> bar b;
> v = b; // copy constructs b into v, first destroying the old foo.
> v.construct<bar>(); // default constructs a bar into v;
> v.construct<bar>(3.14f); // constructs a bar into v using the
> constructor that takes one float;
I plan to eventually support something like the following:
boost::variant< foo,bar > v( inplace<foo>(...) );
v = inplace<bar>(...);
I believe it will enable you to do what you want. Unfortunately, it will
not be ready for the upcoming 1.31 release.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk