compile-time opIndex

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 31 14:35:18 PST 2014


On Wednesday, 31 December 2014 at 22:05:37 UTC, H. S. Teoh via 
Digitalmars-d wrote:
> Point. But that means we've gone nowhere with AA .byPair().
>
> If I wanted to stir up controversy, I'd say that the ultimate 
> cause of
> this issue was the fact that struct fields can't be ref; 
> otherwise it
> would be a non-problem (make .key and .value ref, and then 
> .tupleof will
> Just Work(tm)).

struct S(Key, Value)
{
     private:
         Key*   _key;
         Value* _value;

     public:
         ref Key key()   @property { return *this._key; }
         ref Key value() @property { return *this._value; }
}

and no need for tuple weirdness.


More information about the Digitalmars-d mailing list