Add generic copy stagedfunction for all types

It is a no-op for all immutable types, and tries to call the default constructor for mutable types.

Supersedes #9246; see that issue for some discussion of this