diff --git a/src/object.di b/src/object.di index 83e6b5356f5..8f29f2d95a8 100644 --- a/src/object.di +++ b/src/object.di @@ -484,18 +484,34 @@ public: return *cast(Value[Key]*)(&p); } - Value[] values() @property + // Note: can't make `values` and `keys` inout as it is used + // e.g. in Phobos like `ReturnType!(aa.keys)` instead of `typeof(aa.keys)` + // which will result in `inout` propagation. + + inout(Value)[] inout_values() inout @property { auto a = _aaValues(p, Key.sizeof, Value.sizeof); - return *cast(Value[]*) &a; + return *cast(inout Value[]*) &a; } - Key[] keys() @property + inout(Key)[] inout_keys() inout @property { auto a = _aaKeys(p, Key.sizeof); - return *cast(Key[]*) &a; + return *cast(inout Key[]*) &a; } + Value[] values() @property + { return inout_values; } + + Key[] keys() @property + { return inout_keys; } + + const(Value)[] values() const @property + { return inout_values; } + + const(Key)[] keys() const @property + { return inout_keys; } + int opApply(scope int delegate(ref Key, ref Value) dg) { return _aaApply2(p, Key.sizeof, cast(_dg2_t)dg); diff --git a/src/object_.d b/src/object_.d index 305b9b215d4..d2d1334aa43 100644 --- a/src/object_.d +++ b/src/object_.d @@ -2170,18 +2170,34 @@ public: return *cast(Value[Key]*)(&p); } - Value[] values() @property + // Note: can't make `values` and `keys` inout as it is used + // e.g. in Phobos like `ReturnType!(aa.keys)` instead of `typeof(aa.keys)` + // which will result in `inout` propagation. + + inout(Value)[] inout_values() inout @property { auto a = _aaValues(p, Key.sizeof, Value.sizeof); - return *cast(Value[]*) &a; + return *cast(inout Value[]*) &a; } - Key[] keys() @property + inout(Key)[] inout_keys() inout @property { auto a = _aaKeys(p, Key.sizeof); - return *cast(Key[]*) &a; + return *cast(inout Key[]*) &a; } + Value[] values() @property + { return inout_values; } + + Key[] keys() @property + { return inout_keys; } + + const(Value)[] values() const @property + { return inout_values; } + + const(Key)[] keys() const @property + { return inout_keys; } + int opApply(scope int delegate(ref Key, ref Value) dg) { return _aaApply2(p, Key.sizeof, cast(_dg2_t)dg);