Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Aware(T) {
- bool changed;
- alias data this;
- @property
- ref T data() {
- return d;
- }
- @property
- void data(T assgn) {
- if(d != assgn) {
- d = assgn;
- changed = true;
- }
- }
- private:
- T d;
- }
- class Test(T) {
- T x;
- }
- unittest {
- Aware!(Test!int) test;
- test = new Test!int;
- test.x = 5;
- assert(test.x == 5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement