Boost logo

Boost :

From: Yitzhak Sapir (yitzhaks_at_[hidden])
Date: 2002-06-18 10:37:30

> -----Original Message-----
> From: David Abrahams [mailto:david.abrahams_at_[hidden]]
> ----- Original Message -----
> From: "Yitzhak Sapir" <yitzhaks_at_[hidden]>
> > If this is part of a constructor initializer list, I believe (but am not sure)
> > that the release() function won't be evaluated until the member is to be
> > initialized.
> Why speculate? Look it up.

I'm really sorry that I didn't look it up prior to writing my message. I've now looked it up, and clarified a bit about the difference between order of allocation vs order of construction on the way.

> > But I think this would be true regardless of whether the
> constructor of
> scoped_ptr takes an auto_ptr or not.
> No. Sorry to be so terse about it, but I don't know what else to say.

Now, after rereading your message, I am thinking maybe you meant using a scoped_ptr as a formal parameter type to the constructor, which is something I didn't think of before (I guess because I authored the message you responded to and was unclear myself and was thinking of what I meant). I meant the case that uses a scoped_ptr as a class member in which case calling release() in the constructor call is too early and a better effect can be achieved by passing the auto_ptr in "as-is" as a parameter to the constructor, and then calling release() later on during the initializer list or the constructor body. If scoped_ptr is a formal parameter, then you're forced to call release() in the constructor call, and if there are other parameters yet to be evaluated that might throw, this breaks the ability to manage the pointer in the face of exceptions (so I see your point now).

Sorry for speculating, and I'll try to get my facts straight in the future.


Boost list run by bdawes at, gregod at, cpdaniel at, john at