static assert(0) in template is a disaster

Nils Lankila NilsLankila at gmx.us
Tue Jun 16 16:57:50 UTC 2020


On Tuesday, 16 June 2020 at 14:26:18 UTC, Stefan Koch wrote:
> On Tuesday, 16 June 2020 at 14:22:25 UTC, Nils Lankila wrote:
>> On Tuesday, 16 June 2020 at 14:19:06 UTC, Stefan Koch wrote:
>>> On Tuesday, 16 June 2020 at 14:05:28 UTC, Nils Lankila wrote:
>>>> Today I've decided to test the new -vtemplates feature.
>>>> I don't know if what i've found is already known but it 
>>>> looks like a dormant disaster in phobos.
>>>>
>>>> [...]
>>>
>>> Are you sure it's not the T.stringof ?
>>
>> yes. I've removed it after changing the else statement.
>
> Thank you very much for finding this.
>
> I'll be having a look at this shortly.

The problem is quite clear.

If a template fails once to instantiate with a given set of 
template parameters then it will always fail with the same set of 
parameters. But if failed instantiation are not stored in

> TemplateInstance[TemplateInstanceBox] instances;

That's sure that this is tried again and again...

Maybe something like an `ErroneousTemplateInstance` class could 
be added as it's probably not reasonable to have a 
TemplateInstance instance for something that is not usable.
Then this failed instance could be stored in an additional map, 
e.g

> ErroneousTemplateInstance[TemplateInstanceBox] failedInstances;


More information about the Digitalmars-d mailing list