On 2010-09-17 21:08:29 -0400, Walter Bright <newshou...@digitalmars.com> said:

Andrei Alexandrescu wrote:
On 9/17/10 10:48 CDT, Michel Fortin wrote:
I understand the intent quite well. I'm talking about what happens if
the source is const?

The whole point is, mutation is the motivator. If you copy an empty hash, no problem because the receiver can't mutate it.

Wouldn't copying a ref counted object require mutating the original?

This is an interesting point. Reference counting requires updating the reference counter which lives alongside the referenced memory. So if you have a const reference-counting struct, you can't make a copy of it because const will transitively apply to the counter too, preventing it from being incremented.

I'm not sure why you're talking about mutating "the original" though. You don't need to update the original smart pointer struct as the reference counter lives with the referenced memory to which you have access in postblit.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to