Weird template instantiation speed?

Steven Schveighoffer schveiguy at gmail.com
Sun Jul 9 14:49:39 UTC 2023


On 7/9/23 7:54 AM, IchorDev wrote:
> While working on some new bindings, I've discovered that if `opAssign` 
> in a struct template "`BindingTempl(T)`" has the return type 
> "`BindingTempl!T` then it adds about 4 seconds to the compile time per 
> instantiation of `BindingTempl`. The added compile time is much lower if 
> a function other than `opAssign` returns `BindingTempl!T`. Is opAssign a 
> particularly bad operator to overload in templates or something?

This is probably a bug somewhere, 4 seconds is too much. A reduced test 
case would be helpful.

But I wanted to note, inside a struct template, the template name (by 
itself) is equivalent to the current instantiation. So just returning 
`BindingTempl` would be equivalent, and might not trigger this problem.

See if that helps.

-Steve


More information about the Digitalmars-d-learn mailing list