[Issue 24688] Parameter by-value keeps const (only in templates)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 30 19:11:00 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24688

--- Comment #2 from Dominikus Dittes Scherkl <dominikus at scherkl.de> ---
(In reply to Nick Treleaven from comment #1)
> To do that, the compiler would have to analyse the body of the template
> function.
No. The strategy is
- create a mutable copy (as it is done for normal functions)
- only if this is not possible, create a const copy
- if a const copy is neccessary, declare the template to take a const T (or,
what I would recommend, take it by const ref T)

--


More information about the Digitalmars-d-bugs mailing list