OK, I stand corrected
Steve
On 10/31/11 12:39 PM, Steve Teale wrote:
On Mon, 31 Oct 2011 07:58:11 -0500, Andrei Alexandrescu wrote:
On 10/31/11 4:43 AM, Steve Teale wrote:
Is there a way to do this. For example if I have
struct A { int a, b, c; }
struct B
{
int p, q, r, s;
this(A a) { p = a.a; q = a.b; r = a.c
On Mon, 31 Oct 2011 17:39:57 +, Steve Teale wrote:
> On Mon, 31 Oct 2011 07:58:11 -0500, Andrei Alexandrescu wrote:
>
>> On 10/31/11 4:43 AM, Steve Teale wrote:
>>> Is there a way to do this. For example if I have
>>>
>>> struct A { int a, b, c; }
>>> struct B
>>> {
>>> int p, q, r, s;
>>
Steve Teale:
> But if B is not mine to mess with?
>
> The two structs have a common type prefix. and D guarantees that there
> are predictable values for the remainder of the larger one, so the
> compiler could presumably figure it out. (Easy for me to say)
Looks like a job for StructuralCast!
On Mon, 31 Oct 2011 07:58:11 -0500, Andrei Alexandrescu wrote:
> On 10/31/11 4:43 AM, Steve Teale wrote:
>> Is there a way to do this. For example if I have
>>
>> struct A { int a, b, c; }
>> struct B
>> {
>> int p, q, r, s;
>> this(A a) { p = a.a; q = a.b; r = a.c; }
>> }
>>
>> A a;
>> B
On 10/31/11 4:43 AM, Steve Teale wrote:
Is there a way to do this. For example if I have
struct A { int a, b, c; }
struct B
{
int p, q, r, s;
this(A a) { p = a.a; q = a.b; r = a.c; }
}
A a;
B b;
b = a;
Use opAssign?
Andrei
Is there a way to do this. For example if I have
struct A { int a, b, c; }
struct B
{
int p, q, r, s;
this(A a) { p = a.a; q = a.b; r = a.c; }
}
A a;
B b;
b = a;