opNext: Simplified ranges

rikki cattermole rikki at cattermole.co.nz
Sat Nov 5 11:34:48 UTC 2022


```d
mixin template NextToRange(ElementType) {
	ElementType _value;
	bool _haveValue;

	@property {
		bool empty() {
			return _haveValue;
		}

		ElementType front() {
			assert(_haveValue);
			return _value;
		}
	}

	void popFront() {
		_haveValue = nextValue(_value);
	}
}
```

You don't need to break a large percentage of the standard library to 
use this ;)


More information about the Digitalmars-d mailing list