On type functions

Steven Schveighoffer schveiguy at gmail.com
Mon May 4 15:42:01 UTC 2020


On 5/3/20 5:22 PM, Stefan Koch wrote:
> On Sunday, 3 May 2020 at 21:14:43 UTC, Max Samukha wrote:
>> On Sunday, 3 May 2020 at 09:35:34 UTC, Stefan Koch wrote:
>>
>>> [...]
>>
>> Cool! Does it mean the following will work?
>>
>> alias[] map(alias f, alias[] a) {
>>    alias[] r;
>>    foreach (e; a)
>>        r ~= f!e; // can we?
>>    return r;
>> }
>>
>> enum isType(alias a) = is(a);
>>
>> static assert([map!(isType, AliasSeq!(1, int, "meh"))] == [false, 
>> true, false]);
> 
> Yes that's what it means!

I had thought this might work, but I'm not sure.

Today AliasSeq parameters can bind to normal parameter lists. If you 
have e.g. AliasSeq!(1, 2, 3), will that bind to an alias[]?

Will you be able to overload with a function that takes 3 ints? I'm 
supposing that it should work, and that if you have a "more specific" 
overload, it would use that instead.

One other thing that is unclear is that map is supposed to take it's 
list *first* for UFCS. This would have to be different, as variadics 
typically come at the end of argument lists.

-Steve


More information about the Digitalmars-d mailing list