compile-time opIndex
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Wed Dec 31 14:44:52 PST 2014
On Wed, Dec 31, 2014 at 10:35:18PM +0000, Dicebot via Digitalmars-d wrote:
> 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.
That's what I have right now. The catch is how to make S behave like a
tuple. Or perhaps that's a fool's errand, and we should rename the
function to .byKeyValue, and leave .byPair for Phobos where it can just
package up .key and .value pairs in std.typecons.Tuple, as people
demanded.
T
--
IBM = I'll Buy Microsoft!
More information about the Digitalmars-d
mailing list