How do I provide reference counting with copy-on-write semantics?
Reference counting can be done with either pointer semantics or reference semantics. The previous FAQ shows how to do reference counting with pointer semantics. This FAQ shows how to do reference counting with reference semantics. The basic idea is to allow users to think they’re copying your Fred objects, but in reality the underlying implementation doesn’t actually do any copying unless and until some user actually tries to modify the underlying Fred object.