Copy-on-write

[3] A copy is only made when needed, ensuring each program has its own version when modifications occur.

This allows them to act as value types without the performance problems of copying on assignment or making them immutable.

Qt uses atomic compare-and-swap operations to increment or decrement the internal reference counter.

Since the copies are cheap, Qt types can often be safely used by multiple threads without the need of locking mechanisms such as mutexes.

With COW, when changes are made, a new version of the file is created while keeping the original intact.

This approach enables features like snapshots, which capture the state of a file at a specific time without consuming much additional space.