Thread overview
isCopyable and isAssignable
Oct 09, 2016
Nordlöw
Oct 09, 2016
James Buren
Oct 09, 2016
Jonathan M Davis
Oct 09, 2016
Jonathan M Davis
October 09, 2016
Now that we have isCopyable from

https://github.com/dlang/phobos/pull/4706

can somebody briefly outline when something fulfills `isCopyable` but not `isAssignable` and vice versa?
October 09, 2016
On Sunday, 9 October 2016 at 07:23:05 UTC, Nordlöw wrote:
> Now that we have isCopyable from
>
> https://github.com/dlang/phobos/pull/4706
>
> can somebody briefly outline when something fulfills `isCopyable` but not `isAssignable` and vice versa?

I would imagine that an intermediate value, or other lvalue, may be copyable, but not assignable.
October 09, 2016
On Sunday, October 09, 2016 07:23:05 Nordlöw via Digitalmars-d-learn wrote:
> Now that we have isCopyable from
>
> https://github.com/dlang/phobos/pull/4706
>
> 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


October 09, 2016
On Sunday, October 09, 2016 07:27:38 James Buren via Digitalmars-d-learn wrote:
> On Sunday, 9 October 2016 at 07:23:05 UTC, Nordlöw wrote:
> > Now that we have isCopyable from
> >
> > https://github.com/dlang/phobos/pull/4706
> >
> > can somebody briefly outline when something fulfills `isCopyable` but not `isAssignable` and vice versa?
>
> I would imagine that an intermediate value, or other lvalue, may be copyable, but not assignable.

Yes, but isCopyable is checking a type, not a value, so that doesn't enter into it. To check any kind of value with isCopyable, you'd have to use typeof on it.

- Jonathan M Davis