Earlier quoted context omitted.
Depends, I bet they can be easily translated to some LINQ like implementation in C++17. List comprehensions are just syntax sugar for map/filter/fold.
A jaunt through SO didn't give anything reasonable. This is what SO had to offer: https://stackoverflow.com/questions/36339533/how-to-generate... , and a quick check of new C++17 features didn't show any that would obviously improve on that. There's nothing implicitly stopping you from doing some macro magic to implement it, but its not there naturally.
#include "cpplinq.hpp"
int computes_a_sum ()
{
using namespace cpplinq;
int ints[] = {3,1,4,1,5,9,2,6,5,4};
auto result = from_array (ints)
>> where ([](int i) {return i%2 ==0;}) // Keep only even numbers
>> sum () // Sum remaining numbers
;
return result;
}
Taken from https://archive.codeplex.com/?p=cpplinqDone with C++11. I only referred C++17, because of the lambda improvements done since they got introduced in C++11.