UFCS functions with both pointers and refs
Dave P.
dave287091 at gmail.com
Wed Dec 16 04:54:20 UTC 2020
On Wednesday, 16 December 2020 at 03:50:07 UTC, Mike Parker wrote:
> On Sunday, 13 December 2020 at 19:02:34 UTC, Dave P. wrote:
>> On Sunday, 13 December 2020 at 18:44:20 UTC, Mike Parker wrote:
>>> On Sunday, 13 December 2020 at 18:31:54 UTC, Dave P. wrote:
>>> [...]
>
> Based on you requirement to use pointers, I assume you're doing
> this for a type you get from a C library. I did the same thing
> for the SDL_Rect type when working with SDL. All I did was
> implement a pointer version of my "extension" functions. When I
> had an instance and not a pointer, I took its address when I
> called the function. If that's inconvenient (lots of generic
> code, perhaps), you can always have the pointer version forward
> to the ref version, but it seems to me like just having the one
> version is the way to go most of the time.
Yeah, in this case the C library is the rest of my program :). I
am porting
an application I had written in C to D in betterC mode piece by
piece and there’s
a good number of functions where it’d be convenient to call them
via UFCs.
Thanks for answering my questions!
More information about the Digitalmars-d-learn
mailing list