3 ms·
That's exactly what the Qt collections do: > Implicit sharing automatically detaches the object from a shared block if the object is about to change and the re
by slavik81 9y ago
That's exactly what the Qt collections do:
> Implicit sharing automatically detaches the object from a shared block if the object is about to change and the reference count is greater than one. (This is often called copy-on-write or value semantics.) [source: http://doc.qt.io/qt-5/implicit-sharing.html http://doc.qt.io/qt-5/implicit-sharing.html]
The C++ language is sometimes a little cruel, though. It's easy to accidentally call the mutable version of a function when the const version would have been sufficient. That can be a performance problem if it causes unnecessary copies.