February 08, 2007
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);

Huh.  I had no idea that free functions could be called this way with a class as the first parameter.  I thought it only worked for arrays.


Sean
February 08, 2007
Sean Kelly 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);
> 
> Huh.  I had no idea that free functions could be called this way with a class as the first parameter.  I thought it only worked for arrays.

Either you're being sarcastic or you didn't even _try_ to compile that...
February 08, 2007
Frits van Bommel wrote:
> Sean Kelly 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);
>>
>> Huh.  I had no idea that free functions could be called this way with a class as the first parameter.  I thought it only worked for arrays.
> 
> Either you're being sarcastic or you didn't even _try_ to compile that...

The latter :-)


Sean
February 08, 2007
"Frits van Bommel" <fvbommel@REMwOVExCAPSs.nl> wrote in message news:eqfj04$e65$1@digitaldaemon.com...

>
> You read that first sentence, right? (especially the parenthesized part)
>
> That was a warning I didn't actually compile these :P.

You know, I wasn't trying to be a dick.


February 09, 2007
Bill Baxter wrote:

>> 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.

I buy a "If it" before the "Works"... I've hit the submit button a bit too early.

Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith@jabber.org, ICQ: 134682867

1 2
Next ›   Last »