On Thursday, 22 October 2020 at 21:55:59 UTC, Jack Applegame
wrote:
There is a funny feature (or bug) in the D language:
static alias this and static operator overloading.
For example
interface Foo {
static {
int value;
void opAssign(int v) { value = v; }
int get
On Thursday, 22 October 2020 at 21:55:59 UTC, Jack Applegame
wrote:
Now we can use type Foo as if it were an lvalue/rvalue:
Foo = 5;
int a = Foo;
int b = Foo + a;
Haha, that's pretty neat!
There is a funny feature (or bug) in the D language:
static alias this and static operator overloading.
For example
interface Foo {
static {
int value;
void opAssign(int v) { value = v; }
int get() { return value; }
alias get this;
}
}
Now we can use
On 02/07/2015 04:46 AM, Mike wrote:
> B)-
> struct StaticRegister {
> static private uint _value;
> @property static uint value() { return _value; }
> @property static void value(uint v) { _value = v; }
>
> alias value this;
> }
>
> void
Another try
E)---
struct StaticRegister {
static private uint _value;
@property static uint value() { return _value; }
@property static void value(uint v) { _value = v; }
static uint opCall(){return _value;}
alias _value this;
}
void ma
Consider this simple example
A)-
struct StaticRegister {
static private uint _value;
@property static uint value() { return _value; }
@property static void value(uint v) { _value = v; }
}
void main(string[] s) {
StaticRegister = 1;
asser