I don't know why but I feel myself confused with struct variables in D. As far as structs are value types this means that they are copied everywhere except when passing from/to functions with ref qualifier.

So what I don't understand is when each of these methods for struct variables are called (postblit/opAssign/constructors). Am I right that postblit is used to assign to struct another value with the same type? But what is used when I assign value of the same type, but with another qualifier (const to mutable, immutable to mutable). Should I overload opAssign instead? Or create special constructor to make new value of type that I need?

I don't understand what is general guideline in such situations, because it's common case when I need create some mutable copy of const or immutable struct data to work with.

Reply via email to