On 06/02/2016 04:59 PM, Ali Çehreli wrote:
'alias this' with property functions work at least for your example:


struct FixedRangeInt {
     int min;
     int max;
     int i_;

     int value() const {
         return i_;
     }

     void value(int i) {
         assert(i >= min);
         assert(i < max);
         i_ = i;
     }

     alias i_ this;
}

void main() {
     auto f = FixedRangeInt(0, 100);
     f += 2;
     assert(f == 2);
}

Ali


The `value` methods are never called here. The checks are not performed.

Reply via email to