Il 31/10/18 18:35, Jason H ha scritto:
I attempted this recently, but failed to figure out how to do the following: QVector<int> triple = apply(QVector<int> {1,2,3},[](item) { return item*3;}); or QVector<int> originals {1,2,3}; QVector<int> triples = originals.apply([](item) { return item*3;});
You do this:
std::vector<int> originals{1, 2, 3}; std::vector<int> triples = originals | ranges::view::transform([](int i) { return i * 3; });
(modulo typos). Possibly even without the <int>, as std containers have CTAD.
Cheers, -- Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest