
On Sun, Nov 28, 2010 at 8:47 AM, Marsh Ray
On 10/28/2010 11:27 AM, John Dlugosz wrote:
I think d.reset(in_place(args)) would do the trick, so I propose that as a logical missing consequence of existing features.
I was (independently) looking for this today and came across this recent thread. So I agree with you that it seems like natural functionality that is conspicuously missing.
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.
Optional even has a construct(in_place) method, but it's protected.
Just assign an in-place factory. Look at http://www.boost.org/doc/libs/1_45_0/libs/utility/in_place_factories.html for more details.
I need to declare a variable but I'm not ready to construct it yet. The type represents an operating system resource so it doesn't have meaningful copy semantics and designing it differently is not possible.
Std::auto_ptr would work except there's no good reason for this to require a heap allocation.
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); HTH -- Dean Michael Berris deanberris.com