isCopyable and isAssignable

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at
Sun Oct 9 01:30:37 PDT 2016

On Sunday, October 09, 2016 07:23:05 Nordlöw via Digitalmars-d-learn wrote:
> Now that we have isCopyable from
> can somebody briefly outline when something fulfills `isCopyable`
> but not `isAssignable` and vice versa?

If it's const or immutable, it could be copyable but not assignable. Also,
someone could specifically @disable opAssign while still allowing copying,
though I don't know why anyone would want to do that.

As for the reverse, @disabling the postblit constructor would disable
copying, and if opAssign takes its argument by ref, then assignment should
still work (though I'm not sure whether it would still work if you didn't
explicitly overload opAssign).

- Jonathan M Davis

More information about the Digitalmars-d-learn mailing list