On 17/05/18 11:22, rikki cattermole wrote:
What is the benefit of opPostMove over copy constructors (not postblit)?
The two are unrelated. A copy is a very different operation from a move. With a copy, you have to figure out how to duplicate the resources used by the object. With a move, no such duplication is needed.
People are somewhat conditioned to treat a move as a "copy+destroy". One certainly may implement it that way. There is a lot of power in not having to do it, though. Think a struct with "@disable this(this)".
The D compiler does moves of structs, whether they are copyable or not. This DIP is about being able to hook this move and fix external and internal references.
Shachar