Boost logo

Boost :

Subject: Re: [boost] [Block Pointer] Update
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-03-13 22:23:38


On 14/03/2016 15:19, Phil Bouchard wrote:
> On 03/13/2016 09:42 PM, Phil Bouchard wrote:
>> On 03/13/2016 06:29 PM, Gavin Lambert wrote:
>>>
>>> Also bear in mind that since people get into bad habits with passing
>>> smart pointers by value instead of by reference, any such type has to be
>>> slice-safe or you invite trouble. (ie. someone is going to construct a
>>> block_root_ptr and then pass it by value as a block_ptr, possibly
>>> destroying the original copy. In that second design, every single child
>>> block_ptr will explode at that point.)
>>
>> I think you are right and I need to add a counter back to the proxy so
>> that root_ptr<> (was block_ptr<>) can be r-values.
>
> I just added support for r-values:
>
> root_ptr<int> foo()
> {
> return new node<int>(9);
> }
>
> int main()
> {
> cout << "R-value:" << endl;
> {
> cout << * foo() << endl;
> }
> cout << endl;
> }
>
>
> What happens there is if you copy a root_ptr<> to another one then it
> will transfer the contents of the internal intrusive list of node<>s to
> the new root_ptr<>.

What about slicing, though? Or have you removed the base-class
association between the two?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk