3 ms·
A jaunt through SO didn't give anything reasonable. This is what SO had to offer: https://stackoverflow.com/questions/36339533/how-to-generate-vector-like-list
by joshuamorton 9y ago
A jaunt through SO didn't give anything reasonable.
This is what SO had to offer: https://stackoverflow.com/questions/36339533/how-to-generate-vector-like-list-comprehension/36340883 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.
- pjmlp 9y agoSO is not the only source of truth. #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=cpplinq https://archive.codeplex.com/?p=cpplinq Done with C++11. I only referred C++17, because of the lambda improvements done since they got introduced in C++11.