div0 wrote:
I've been having a play and as far as I can tell it looks like aliasing
this to a method just doesn't work at all; I think the alias this is
being completely ignored.
It would seem you're right. Just that assignment made me think it did
work. Now why does the assignment work? I
On 24/06/2010 19:23, Simen kjaeraas wrote:
div0 wrote:
This code fails on the line 'int b = f;'. Is it supposed to?
I think so.
'alias this' is used to forward stuff that appears to the right of a
dot onto the named member.
Not only. Assignment of the wrapped type will also work.
Yes,
On Thu, 24 Jun 2010 14:23:09 -0400, Simen kjaeraas
wrote:
It does not. In WalterAndrei.pdf, opImplicitCast(To|From) is mentioned,
but it has not found its way into the language.
Alias this is supposed to implement what opImplicitCast was supposed to
implement. opImplicitCast is not going
div0 wrote:
This code fails on the line 'int b = f;'. Is it supposed to?
I think so.
'alias this' is used to forward stuff that appears to the right of a dot
onto the named member.
Not only. Assignment of the wrapped type will also work.
In c++ to get what you are doing to work, you'd
On 24/06/2010 13:52, Simen kjaeraas wrote:
struct Ref( T ) {
T* payload;
@property ref T getThis( ) {
return *payload;
}
@property ref T getThis( ref T value ) {
payload = &value;
return *payload;
}
alias getThis this;
}
void bar( ) {
Ref!int f;
int n;
f = n;
int b = f;
}
This code fails on the
struct Ref( T ) {
T* payload;
@property ref T getThis( ) {
return *payload;
}
@property ref T getThis( ref T value ) {
payload = &value;
return *payload;
}
alias getThis this;
}
void bar( ) {
Ref!int f;
int n;
f = n;
int b = f;
}
This code fails on the line 'int b