> To have type-erased containers, we need to go back to something like java.lang.Collection.
C++20 offers coroutines which allows the same things without java-like type hierarchies though (and with much more flexibility as you don't even need to have an actual container existing somewhere - your function's stack can serve as one just fine :p). see e.g. https://godbolt.org/z/cEv7Gp - in simple cases it optimizes as well as as a std::vector. Well, for Qt 7 maybe :-) On Thu, May 14, 2020 at 9:00 PM Thiago Macieira <thiago.macie...@intel.com> wrote: > On Thursday, 14 May 2020 02:33:43 PDT Marc Mutz via Development wrote: > > On 2020-05-14 02:15, Thiago Macieira wrote: > > > On quarta-feira, 13 de maio de 2020 01:41:26 PDT Иван Комиссаров wrote: > > >> std::span<Product> Project::productsSpan() const & { return > > >> d->products; } > > >> std::span<Product> Project::productsSpan() const && = delete; > > > > > > Now implement either or both of these functions if internally you have > > > a > > > QSet<Products>. > > > > Now implement QHash<Qt::ItemRole, QByteArray> roleNames() when > > internally you have a std::pmr::unordered_map<Qt::ItemRole, > > std::pmr::string>, with all the data allocated from one > > std::pmr::monotonic_buffer_resource. > > > > This does both ways. > > No, it doesn't. In both you created a copy on demand. > > But you can only *return* said copy if the return type is an owning > container. > std::span and the views are not. > > > And: you can also have views over associated data structures, they just > > can't have inline functions because they need to type-erase the > > container. For an extreme example, consider QAssociativeIterable. > > Which is: > a) a horrible API > b) misspelling "iteratable" > > To have type-erased containers, we need to go back to something like > java.lang.Collection. > > -- > Thiago Macieira - thiago.macieira (AT) intel.com > Software Architect - Intel System Software Products > > > > _______________________________________________ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development >
_______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development