opIndexDispatch?

Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 12 17:13:12 PDT 2016


On Wednesday, 12 October 2016 at 23:14:26 UTC, Jonathan M Davis 
wrote:
> opIndexUnary, opIndexAssign, and opIndexOpAssign exist to make 
> it possible to do some basic operations on the result of 
> foo[bar] without having to have opIndex return by ref, but 
> assuming that you can return by ref, all of them could be done 
> by having opIndex return by ref.

No? If I want to mimics opIndex* by having opIndex return a ref. 
I would need to create a new entry every time opIndex is used to 
access a non-existent key, whether the return value is used as a 
lvalue or not. And opIndex* will solve this problem.


More information about the Digitalmars-d-learn mailing list