On Friday, 3 June 2016 at 21:04:41 UTC, ag0aep6g wrote:
Thank you ag0aep6g, especially for the missing shared in my static this !

Since I'm implementing a (hopefully useful) library, it would be unpleasant for users to have to cast away shared to print the info.

It works with immutable at the condition that I declare the toString() method like this

    string toString() immutable {...}

There is also no missing opEqual.


Is it possible to instantiate immutable objects by using emplace and modify the object in the toString() call ? This is to cache the resulting string to avoid creating a new string at each call.

I would have to cast away the immutable attribute of 'this'. Is this possible ? Note that the objects would be instantiated by emplace in a void array at start up. So the memory is writable.

Reply via email to