On Friday, 26 July 2024 at 02:34:12 UTC, Andy Valencia wrote:
On Thursday, 25 July 2024 at 13:07:03 UTC, Jonathan M Davis wrote:

It's most definitely not a bug that IFTI (Implicit Function Template Instantiation) instantiates the template with the exact type that it's given.

The "principle of least astonishment" certainly supports this behavior. To check my understanding, I forced the type of instantiation:

  writeln(test2!int(v));

and that worked as I expected.

Andy

Yes, it's pretty much the same "solution" but on the caller side instead of the callee. But it works only for types like int or which provides a constructor that generates a mutable copy.

Reply via email to