Defining an alias to an overloaded function
Boris Carvajal
boris2.9 at gmail.com
Tue Jan 21 04:44:43 UTC 2020
On Monday, 20 January 2020 at 22:02:54 UTC, olvy wrote:
> I'm learning D, and as an exercise, I'm trying to define a
> HashSet that would be a wrapper around an associative array
> with some dummy value type.
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");
}
More information about the Digitalmars-d-learn
mailing list