What I find painful about writing pseudo-functional C++ using <algorithm> and other tricks is that you have to allocate storage for intermediate values. This makes C++ algorithms a lot less composable than similar things in other languages.<p>So if I wanted to do something like (in Haskell):<p><pre><code> sumOfOddSquares xs = sum . map (^2) . filter odd $ xs
</code></pre>
In C++, I would need to allocate temporary storage for the intermediate values.<p><pre><code> std::vector odd_numbers;
std::copy_if(xs.begin(), xs.end(), back_inserter(odd_numbers), isOdd);
std::transform(odd_numbers.begin(), odd_numbers.end(), odd_numbers.begin(), square);
std::accumulate(odd_numbers.begin(), odd_numbers.end(), 0, plus);
</code></pre>
This becomes quite painful very quickly. You can use solutions like boost::filter_iterator, but soon you're knee deep in C++ templates and the long compile times and awful error messages that follow.<p>The example above is a bit contrived since it can be easily be done with a single accumulate, but you get the idea...<p><pre><code> std::accumulate(xs.begin(), xs.end(), 0,
[](int sum, int i) { return sum + ((i&1) ? i*i : 0); });
</code></pre>
So while you can have lots of fun with <algorithm>, it's quite limited in what it can do.