Boost logo

Boost Users :

Subject: Re: [Boost-users] Usage of Boost.Optional
From: Marsh Ray (marsh_at_[hidden])
Date: 2010-11-27 19:47:11


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.

Optional even has a construct(in_place) method, but it's protected.

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.

- Marsh


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net