I presume MyNonCopyable()
is concretely a non-copyable type, so let y = x
would in fact move x
into y
rather than copy it. When we generalize the generics system to include noncopyable types, then withHandle
can't assume Handle
is copyable, and it would act as a noncopyable type within the body of the function. So the function would not be able to introduce copies of whatever Handle
is, but callers can still pass in copyable types for the Handle
that they can copy themselves.
You may also be interested in the @noImplicitCopy
attribute, which we're implementing to suppress implicit copying on values that are of copyable type.