Defining an alias to an overloaded function

olvy olvy at olvy.ol
Thu Jan 23 20:24:52 UTC 2020


On Tuesday, 21 January 2020 at 04:44:43 UTC, Boris Carvajal wrote:
> This seems to work:
>
> ...
>     struct RangeImpl(T) {
>         alias byKeyRetType = 
> typeof(byKey!(int[T])((int[T]).init));
>         byKeyRetType keyRange;
>         this(ref int[T] d) {
>             keyRange = d.byKey;
>         }
>         bool empty() {
>             return keyRange.empty;
>         }
>         ...
>     }
>
>     RangeImpl!T opSlice() {
>         return RangeImpl!T(_dict);
>     }
> }
>
> void main()
> {
>     ...
>     if (h[].all!(nn => nn < 5)) {
>         writeln("less than 5");
>     }

Thank you very much!  I have completely forgotten about typeof().

I see you also fixed my unnecessary (T) template parameter to 
opSlice, which also caused a compilation error in addition to the 
first mistake.  I think this is because it "shadows" the original 
T parameter from the struct itself, right?




More information about the Digitalmars-d-learn mailing list