On 11/27/2010 06:57 PM, Dean Michael Berris wrote:
I'm not sure you understood the resolution of the discussion -- you will need to use the Boost.In_place_factory utility if you want to construct the resource in-place.
Haha, probably not. I admit to skimming it quickly mostly to confirm my preconceptions. Looks like there were a couple more emails in the thread.
On Sun, Nov 28, 2010 at 8:47 AM, Marsh Ray
wrote: Boost::optional is exactly what I want, it's just that it unnecessarily requires a copy for deferred initialization.
It's not required. You can use the in place factory for that.
optional<foo> o; o = in_place<foo>(parameters, to, foo);
Cool, it works! (Rather it compiles, so I'll assume it works for now.) Still, the documentation says it shouldn't: http://www.boost.org/doc/libs/1_45_0/libs/optional/doc/html/boost_optional/d...
optional& optional
::operator= ( T const& rhs ) ;
Notes: If *this was initialized, T's assignment operator is used, otherwise, its copy-constructor is used.
No mention of using in_place with operator=. Thanks, - Marsh