Rainer Deyke wrote:
Christopher Wright wrote:
What mechanism for sharing state is available to by-reference objects
but not by-value objects?

struct C {
  T t;
}

C c1;
C c2 = c1;

If T was a reference type, 'c1' and 'c2' now share state, and it's up to
the programmer to write code to prevent this.

No, they don't. Each instance of C has its own copy of the 't' reference.


Moreover, the D language
doesn't even give a hint as to whether T or a reference type or a value
type.

Like you can't write "typedef X* T;" in C...


If T is a template parameter, it could be both.

That's what IsExpression and static assertions are for.


--
Tomasz Stachowiak
http://h3.team0xf.com/
h3/h3r3tic on #D freenode

Reply via email to