Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 19 March 2025 at 22:26:54 UTC, WhatMeWorry wrote: ``` bool wasFound(I)(I result) { return(result != -1); } bool existPoint(Point b, int cost) { auto i = closed.countUntil(b); if(wasFound(i)) // -1 is returned if no point b is found in

simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread WhatMeWorry via Digitalmars-d-learn
``` bool wasFound(I)(I result) { return(result != -1); } bool existPoint(Point b, int cost) { auto i = closed.countUntil(b); if(wasFound(i)) // -1 is returned if no point b is found in the range ``` The above compiles and executes successfully. But

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 19, 2025 at 10:26:54PM +, WhatMeWorry via Digitalmars-d-learn wrote: [...] > The above compiles and executes successfully. But the following fails > with: app.d(179,13): Error: no property `wasFound` for `i` of type > `long` > > I thought the templated function would take care of

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 19, 2025 at 11:21:15PM +, monkyyy via Digitalmars-d-learn wrote: [...] > ufcs on local functions is hit or miss; [...] I thought it was always a miss. :-D At least, it's never worked for me every time I tried it. I always have to move the UFCS function to module scope, then it wo

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 19, 2025 5:48:37 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: > On Wed, Mar 19, 2025 at 11:21:15PM +, monkyyy via Digitalmars-d-learn > wrote: > [...] > > ufcs on local functions is hit or miss; > [...] > > I thought it was always a miss. :-D At least, it's never work

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 20 March 2025 at 02:01:25 UTC, Jonathan M Davis wrote: On Wednesday, March 19, 2025 5:48:37 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: I thought it was always a miss. :-D At least, it's never worked for me every time I tried it. I always have to move the UFCS function to mo