From: Eric Friedman (ebf_at_[hidden])
Date: 2003-10-27 20:25:59
David Abrahams wrote:
> Eric Friedman <ebf_at_[hidden]> writes:
>>>is calling a nothrow constructor, then the "destroy, then create"
>>>ordering can still preserve the strong guarantee, it seems.
>>Variant provides the basic guarantee for assignment lhs = rhs by
>>copying the content of lhs onto the heap before its destruction. Then
>>the content of rhs is copied to the storage of lhs. In the event of
>>success, the backup is destroyed; in the event of an exception, the
>>lhs variant stores a pointer to the backup and "redirects" all
>>visitation requests accordingly.
> What a surprise. Why would you want to pay for the copy back to the
> stack once you've paid for heap allocation? I guess if you're worried
> about sucking up heap memory it might be important. If you're worried
> about speed it could be bad. Hmm, sounds like a policy :(.
I'm confused. You're not actually surprised, are you?
Attempting a copy back to the stack would not do much to solve the
problem. After all, if this copy fails, then we are still stuck with the
need to redirect visitiation requests to the heap backup.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk