On 16 March 2012 17:14, Adam D. Ruppe <destructionator@gmail.com> wrote:
On Friday, 16 March 2012 at 15:10:06 UTC, Manu wrote:
Interesting approach, how will that affect 'thing's type?

It will strictly be myAttribute!int, but alias this
means that you can pass it anywhere an int is expected
too (and assign ints to it all the same).

Check it:

void cool(int a) {}
void main() {

       myAttribute!int thing;
       thing.refresh = true;

       thing = 10; // we can assign ints to it, like if it was an int
       assert(thing.bNeedsAttention); // should be unchanged

       int a = thing; // no problem, thing is usable as an int
       assert(a == 10);

       cool(thing); // ditto
}

I can see that it might work nicely in very simple cases, but it could get nasty in complex constructs. If some template tries to take the typeof for instance, now I'm cloning the attributes functionality too, which I don't think is desirable...