[Interest] Qt API annoyances: where to log/discuss?
Jason H
jhihn at gmx.com
Wed Oct 31 21:59:19 CET 2018
> Sent: Wednesday, October 31, 2018 at 4:30 PM
> From: "Giuseppe D'Angelo via Interest" <interest at qt-project.org>
> To: interest at qt-project.org
> Subject: Re: [Interest] Qt API annoyances: where to log/discuss?
>
> 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.
Thanks Giuseppe! That's getting closer :-) however the expression boggles my mind. "originals | ranges::view::transform" there's a lot of compiler voodoo there. I'm trying to keep up on all the C++0xYZ developments, and still trying to wrap my head around SFINAE. I had to look up CTAD, and that looks like a very good enhancement. I think Qt should hide a lot of that compiler iteration from me ;-) It is an unfortunate phenomenon that I am spending more time decrypting compiler Voodoo. I am thinking that C++ is less a language for writing things in, and rather a language for programming a compiler with the secondary goal of creating an application. <soapbox warning> Too much is being spent on telling the compiler how to build it, rather than just building it. I think this is one thing that Qt can (and should) restore the balance on. "Code less, create more." Spend less time figuring out how to tell the compiler to build it, and let Qt apply() (pun intended) it's transforms to make my effort about application programming not compiler programming.
More information about the Interest
mailing list