Swift 中的哪些值类型支持写时复制?

Which value types in Swift supports copy-on-write?

我在 Swift here.

中阅读了数组的写时复制实现

Arrays, like all variable-size collections in the standard library, use copy-on-write optimization. Multiple copies of an array share the same storage until you modify one of the copies. When that happens, the array being modified replaces its storage with a uniquely owned copy of itself, which is then modified in place. Optimizations are sometimes applied that can reduce the amount of copying.

我想知道您是否有关于哪种结构支持写时复制的信息。

String 和所有集合类型支持写入时复制 - ArrayDictionarySet

除此之外,编译器可以自由优化任何结构访问并有效地为您提供写时复制语义,但不能保证。