const and immutable values, D vs C++?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Wed Dec 4 22:57:19 UTC 2019


On Wednesday, 4 December 2019 at 22:51:01 UTC, Ola Fosheim 
Grøstad wrote:
> Is there a way to specify in generic code that you want the 
> best fit of a const/immutable reference depending on the return 
> type (but not a mutable one)?

I mean, if f() return mutable or const then it should be const, 
but if it returns immutable then it should be immutable. 
Something like:

readonly myref = f()




More information about the Digitalmars-d-learn mailing list