POV-Ray : Newsgroups : povray.off-topic : Coding in the mainstream : Re: Coding in the mainstream Server Time
29 Jul 2024 10:25:20 EDT (-0400)
  Re: Coding in the mainstream  
From: clipka
Date: 8 Jun 2012 04:13:26
Message: <4fd1b426$1@news.povray.org>
Am 07.06.2012 16:35, schrieb Warp:
> clipka<ano### [at] anonymousorg>  wrote:
>> The only caveat not explicitly warned about in the smart pointers
>> documentation is that the smart pointer assignment operator ("=") is
>> implemented as a swap operation, so to create another smart pointer
>> referencing the same object you need to explicitly make use of the smart
>> pointers' copy constructor:
>
> That makes no sense. It would break basically everything if it were like
> that.

That's what I thought when I first saw it (or, rather, imagined to see it).

> You are confusing it with how operator= of some versions of shared_ptr might
> be implemented, in that it internally swaps its contents with a temporary
> that has been initialized with the parameter (this is done to avoid problems
> that would happen when assigning to itself). Externally there's no swapping
> behavior (and there can't be).

Hm... I just re-read the boost shared_ptr assignment specs, and you're 
obviously right. How I read that misconception into the docs I have no 
idea (it's been unchanged for ages), but for obvious reasons it stuck.

I guess I'm just having a bit of cleanup work in the POV-Ray code cut 
out for me...


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.