2 ms·
It's not? This is literally the function that I found I should use when I wanted to fold over a list I had. What would you recommend I use?
by tinco 4y ago
It's not? This is literally the function that I found I should use when I wanted to fold over a list I had. What would you recommend I use?
- moloch-hai 4y agoThe library function is fine, although the long name is unfortunate. The apparatus around applying it, in the example, is aggressively weird.
- tinco 4y agoI agree that the example is crazy. But the function is not fine, it's a testament to how unhinged the C++ standards committee is. Its existence is proof that the problems of C++ are not just with its history, but that it is an ongoing snowball of incompetence and bad decisions.
- moloch-hai 4y agoIt is hard to know what you are talking about. It applies linear operators to an input sequence, defaulting to + and x, or whatever you specify. It is like inner_product, but sequence order is not specified. There is a "range" version in C++20 that in use looks more like in other languages. (It is technically C++23, but appears in libraries shipped with C++20.)
- tinco 4y agoIt seems like a small thing, but everything about it is just slightly wrong. That it's called `transform_reduce` and not just `reduce`. The fact that it was in C++17 alongside a function called `reduce` that's basically useless. Why was it not in C++14? Why was it not in C++11? Why was it not in C++03? That in 2017 the C++ standard committee was still introducing misdesigned cruft like std::reduce to the language says everything you need to be about C++, it's a clusterfuck.