Make all functions from std.typecons "Proxy" inout
Namespace
rswhite4 at googlemail.com
Tue May 8 23:42:07 PDT 2012
On Wednesday, 9 May 2012 at 04:49:39 UTC, Kenji Hara wrote:
> On Tuesday, 8 May 2012 at 22:58:07 UTC, Namespace wrote:
>> In my development of the Ref / NotNull structure, I came
>> across a
>> problem: All the methods of "Proxy" aren't "inout". Has this a
>> reason or will change? In my opinion they should all be
>> "inout".
>> I mentioned previous self fixes in my corresponding "Ref /
>> NotNull" thread already.
>
> It is necessary. See following conceptual code:
>
> struct S
> {
> void f() {}
> void g() {}
> }
> struct Proxy(T)
> {
> T o;
> void f()() inout { return o.f(); }
> void g(this T)() { return o.g(); }
> }
> void main()
> {
> Proxy!S p;
> //p.f(); // inside Proxy.f, typeof(o) == inout
> p.g();
> }
>
> 'Proxy' object should forward its 'this' type to original
> object.
> For the purpose, TemplateThisParameter ('this T') works as
> expected.
>
> Kenji Hara
I thought, "inout" is evaluated by the compiler and make the
method either const or not
If not, then I understand, "inout" probably not yet complete.
But in this case you would have to offer just two methods:
void f () () {return o.f ();}
void f () () const {return o.f ();}
More information about the Digitalmars-d-learn
mailing list