Subject: Re: [boost] temp_ptr<> - preventing use as a member
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-11-15 12:58:52
Gottlob Frege wrote:
> For example, a pointer passed into a function, that is only
> valid for the lifetime of the function call. A temp_ptr or
> callstack_ptr or ... some better name.
> So this pointer would need a copy constructor so it can be
> passed along into a function (I don't think requiring a ref to
> the pointer would be good; I'd rather pass by value).
If you relax this restriction,...
> To prevent constructing one via the copy constructor that will
> be kept around, I can define a custom new operator but keep it
...you can avoid the need to do that...
> The only thing, I think, that I can't prevent, is construction
> of a new wrapper struct that has a temp_ptr as a member (which
> is copy constructed in wrapper's constructor). Can anyone
> think of a way to prevent that?
...and prevent users from doing that, by making the type noncopyable.
IOW, the only permissible parameter type using temp_ptr would be reference or pointer (const or not).
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk