This is going to sound stupid, but how do you have two pointers'
targets copy each other? since pointers are used like reference
types, how do you write the C++ equivalent of "*p1 == *p2"
Here is the context of what I'm trying to do:
----
struct S
{
struct Payload
{}
Payload payload;
@property
typeof(this) dup()
{
typeof(this) ret;
if(payload)
{
ret.payload = new Payload;
ret.payload = payload; //Copies the payload? The pointer?
}
return ret;
}
}
----
So yeah, that was my question. I'd be tempted to write:
ret.payload.field1 = payload.field1;
ret.payload.field2 = payload.field2;
...
But:
1) It feels hackish and just going around the problem
2) It works for pointer to Struct with fields, but what about
things like "int*" ?
Oh yeah, also, if you have a better idea for an better (cleaner)
implementation of a "payload based" "reference type" structs, I'm
all ears.