On Sat, 02 May 2009 15:17:04 -0400, Rainer Deyke <rain...@eldwood.com>
wrote:
Robert Jacques wrote:
On Sat, 02 May 2009 03:39:27 -0400, Rainer Deyke <rain...@eldwood.com>
wrote:
You can have non-copyable value types, but they can't be containers.
No they don't. Iteration can often be destructive. If I iterate over a
stack or a queue, I'm left with an empty stack/queue. For value
semantics to work non-destructive copying is required.
OK. I grant that there are non-copyable types that can reasonably be
called containers. Simple solution: make them non-copyable structs.
You still get most of the benefits of value types:
- One less layer of indirection.
Again, D array's are structs with reference semantics. This isn't a
pro/con either way.
- No long distance dependencies.
Well, if I can't copy it, then I have to use ref everywhere, which is
functionally equivalent to reference semantics. I think you've just proved
the counter-point.
- RAII.
Can be done with structs or classes. Also see point 1. So, this isn't a
pro/con either way.