On 12/06/2019 18.14, Matthew Woehlke wrote: > On 22/05/2019 12.41, Konstantin Tokarev wrote: >> In the latter QList can be replaced with >> std::vector<std::unique_ptr<T>> or QVector<std::unique_ptr<T>> > > No, it can't. `QList<T>` has value semantics w.r.t. `T`. Your > "alternatives" have pointer semantics.
And, to be clear... while having to write `*` and `->` is annoying, it gets worse: good_list.append(value); // Never mind that we can't 'append'... bad_list.emplace_back(new /* AIEE! */ value_t{value}); bad_list.emplace_back(std::make_unique<value_t>(value)); ...and worse: auto evil = std::move(bad_list[i]); bad_list[i]->frob(); A `QList<T>` *always* has a value at a valid index. Your proposed "alternatives" don't have that guarantee. A `vector<std::unique_ptr<T>>` is simply **NOT** a replacement for `QArrayList<T>`. Period. -- Matthew _______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development