D23918: RFC: Drop Outputs class
Roman Gilg <[email protected]>
| Newsgroups | gmane.comp.kde.devel.kwin |
|---|---|
| Message-ID | <[email protected]> |
romangg added a comment. In D23918#530689 <https://phabricator.kde.org/D23918#530689>, @zzag wrote: > I haven't received any strong arguments why we need a subclass of QVector<AbstractOutput *>. Outputs overloads constructor to implement some sort of covariance. However, that doesn't qualify as a good argument because the right solution would be to add a helper function that could perform these conversions. > > In many cases, inheriting from a vector type is a no-no. You should do that only if there's no any other way around. You need to provide sources for such generic statements. If you would be a computer science professor of 30 years I would believe them without asking for such but we are not. > --- > >> This change makes everything too explicit. Boo! > > I personally don't consider it to be a problem. That's C++ after all. > > Templates are invariant and making conversions between Collection<Base> and Collection<Derived> explicit is a good thing because this way we have less magic in the code. Independent of researched facts I agree though with Vlad that the qvector_cast feels better since it's more explicit and David's QVector subclassing, while being an interesting solution, feels kind of forbidden magic in comparison. INLINE COMMENTS > utils.h:240 > + QVector<To> mapped; > + mapped.reserve(collection.size()); > + std::copy(collection.constBegin(), collection.constEnd(), std::back_inserter(mapped)); For simple data types according to Qt docs resize is faster. It's a micro-optimization, but since the outputs are queried often maybe it's worth it. I assume we could use template specialization for `AbstractOutput*` as `To` type, or just use no template at all? Although having a templated qvector_cast is nice. REPOSITORY R108 KWin REVISION DETAIL https://phabricator.kde.org/D23918 To: zzag, #kwin Cc: romangg, davidedmundson, alexeymin, kwin, LeGast00n, The-Feren-OS-Dev, sbergeron, jraleigh, fbampaloukas, GB_2, mkulinski, ragreen, jackyalcine, Pitel, iodelay, crozbo, bwowk, ZrenBot, ngraham, himcesjf, lesliezhai, ali-mohamed, hardening, jensreuterberg, abetts, sebas, apol, mart