Code duplication where you wish to have a routine called with either immutable or mutable arguments

Ali Çehreli acehreli at yahoo.com
Tue May 30 04:15:22 UTC 2023


On 5/29/23 19:57, Cecil Ward wrote:

 > I wish to have one routine
 > that can be called with either immutable or (possibly) mutable argument
 > values.

'const' should take both immutable and mutable. Can you show your case 
with a short example?

 > Could I make the one routine into a template?

That could work but give 'in' parameters a try:

   https://dlang.org/spec/function.html#in-params

Ali



More information about the Digitalmars-d-learn mailing list