28.12.2010 20:42, David Nadlinger пишет:
On 12/28/10 2:09 AM, Stanislav Blinov wrote:
I don't think I got what David meant with it either. Assigning instances
of the same type is perfectly valid as long as you do not define some
very peculiar opAssign.

The point here is that person1 and person2 are not instances of the same type, try compiling the following snippet:

---
struct Human {
   string name;
   int age;
}

void main() {
   Human person1;

   typedef Human Mankind;
   Mankind person2 = person1;
}
---

Oh, right, I missed that one, sorry.

This might not be what Hamad wanted to know when he asked »but why that code works«, but I could think of no other reason why the snipped he posted should fail to compile.

Yes, the original snippet should compile fine because typedef'd type isn't actually used in any way except for accessing fields, which of course have built-in types.

Reply via email to