maolike

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Behind the scenes, QString uses implicit sharing (copy-on-write) to reduce memory usage and to avoid the needless copying of data.
QVector也是隐式数据共享的;虽然文档没说但是看代码能知道

inline QVector(const QVector<T> &v) : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }

posted on 2019-01-22 10:24  maolike  阅读(406)  评论(0编辑  收藏  举报