From the D Blog: (Ab)using Overload Sets to Create Ad-Hoc Template APIs
jmh530
john.michael.hall at gmail.com
Wed Jul 22 01:01:31 UTC 2026
On Tuesday, 21 July 2026 at 23:53:48 UTC, Kapendev wrote:
> On Tuesday, 21 July 2026 at 23:41:28 UTC, jmh530 wrote:
>> In the part about GVec, what if you already have code that
>> relies on the library with GVec2/3/4 and want to integrate it
>> with this?
>
> I think it's an easy change. Something like:
>
> ```d
> // Old: GVec2(T) { ... }
> GVec(T, int N : 2) { ... }
> alias GVec2(T) = GVec!(T, 2);
> ```
>
> The reason why I haven't done it is because I prefer the
> simplicity of a single template argument. It's an opinion. I
> might change it one day.
I'm thinking about the situation where you have functions that
take on an old GVec2 as an input and you don't have the ability
to change the original GVec2 source code. Wouldn't you have two
GVec2's in scope if you do something like this?
More information about the Digitalmars-d-announce
mailing list