static map as a type function

Steven Schveighoffer schveiguy at gmail.com
Wed Sep 23 14:32:46 UTC 2020


On 9/23/20 10:15 AM, Meta wrote:
> On Wednesday, 23 September 2020 at 14:05:50 UTC, Steven Schveighoffer 
> wrote:
>> On 9/23/20 9:38 AM, Stefan Koch wrote:
>>> static_map_tf.d(12): vtemplate: 3 (3 unique) instantiation(s) of 
>>> template `static_map_tf(alias F)(alias_array types...)` found
>>
>> Ah ok. You meant the static map template is going to be different 
>> because the lambdas are considered different aliases.
>>
>> That's standard behavior for the current compiler too. I thought you 
>> meant that type functions have an extra problem with templates using 
>> lambdas.
>>
>> It makes me wonder -- can the compiler determine identical lambdas and 
>> reduce template instantiations? This was one of the problems with 
>> moving from string lambdas to actual lambdas.
>>
> 
> There was some limited support for lambda comparison added in 2.079:
> https://dlang.org/changelog/2.079.0.html#lambdacomp

OK, so this is possible in some circumstances. A good update to dmd 
would be to identify such "comparable" lambdas, and merge their template 
instantiations into one.

-Steve


More information about the Digitalmars-d mailing list