pointers-to-members, (custom) array implementation

Bill Baxter dnewsgroup at billbaxter.com
Thu Feb 8 08:02:53 PST 2007


Wolfgang Draxinger wrote:
> BCS wrote:
> 
>> I'd have to check but I think this works
>>
>> class C
>> {
>> int one(int i){...}
>> int two(int i){...}
>> int three(int i){...}
>> }
>>
>> int Pt2Mem!(alias go)(C c, int i)
>> {
>> return c.go(i);
>> }
>>
>>
>> auto fn = &Pt2Mem!(one);
>>
>> C c = new C;
>>
>> c.fn(1);
> 
> Works but is IMHO not very elegant. Make PtM a language feature
> and it's get a lot more readable. I don't like it.

No, it does not work.  &Pt2Mem!(one) gives a 'what's "one"?' error.
And the c.fn part gives a 'no such member "fn"' error.

But if it did work I think it would be a pretty reasonably elegant way 
to do it. :-)


--bb



More information about the Digitalmars-d mailing list