Lazily evaluated property pointing to read only object

mikey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 24 03:59:50 PDT 2016


On Saturday, 24 September 2016 at 10:16:34 UTC, Basile B. wrote:
> You don't need to cast, from "mutable" to "const" is implicit:
> https://dlang.org/spec/const3.html#implicit_conversions

Ok, but using const would be an accepted way of doing this? The 
options I could see were to have "_o" as a const or immutable 
type and just create a const on the first call to the lazily 
evaluated property, or to do what I did and have "_o" as a 
non-const and then convert it to cost on the way out. However

To store it as const I guess I'd have to make it a non-const 
pointer to a const object, and is that not kind of what immutable 
is?




More information about the Digitalmars-d-learn mailing list