Associative Arrays with elements having function type?
monkyyy
crazymonkyyy at gmail.com
Mon Nov 3 22:42:34 UTC 2025
On Monday, 3 November 2025 at 22:36:56 UTC, monkyyy wrote:
> On Monday, 3 November 2025 at 21:29:47 UTC, kdevel wrote:
>> Yesterday I read
>>
>> 3. Neither the KeyTypes nor the element types of an
>> associative array
>> can be function types or void.
>>
>>
>
> I read this as poorly written for "aa's dont magically know how
> to look up typeinfo" and have never ran into such a restriction
compiles:
```d
int foo(int){return 1;}
int bar(int a){return a;}
alias T=typeof(&foo);
T[T] foobar;
unittest{
foobar[&bar]=&foo;
foobar[&foo]=&bar;
}
```
More information about the Digitalmars-d
mailing list