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

Steven Schveighoffer schveiguy at gmail.com
Tue May 30 15:38:35 UTC 2023


On 5/29/23 10:57 PM, Cecil Ward wrote:
> I have often come into difficulties where I wish to have one routine 
> that can be called with either immutable or (possibly) mutable argument 
> values. The argument(s) in question are in, readonly, passed by value or 
> passed by const reference. Anyway, no one is trying to write to the 
> items passed in as args, no badness attempted.

In cases where const doesn't suffice, inout might. inout has a feature 
that it can be used in cases where a const nested behind multiple 
references would not work.

-Steve


More information about the Digitalmars-d-learn mailing list