It seems that the algorithms in ranges v3 aren't chainable, i.e:
const auto ints = std::vector<int>{1,2,1,3,1,4,1,5,1,6};
const auto num_ones = ints | ranges::count(1);
... has to be written functional style:
const auto num_ones = ranges::count(ints, 1);
Is this a design choice that only algorithms/actions which returns a new range/container are pipeable?
Some algorithms are actually chainable and you find them in the view and/or action namespace.
But your code suggest that you have a different question actually. Why are there no algorithms with a signature allowing to end a pipe chain? I suggest the namespace
reducer
for such algorithms. Here is a working code example:Eric Niebler said, that people shoot many ideas out of the hip, like we do, but do not see the profound consequences. So maybe there is something bad about the idea that we do not see. Would be great if he passes by your question and enlighten us with a comment.
Of course he was using C++11 for ranges-v3 and without typededuction for constructors this idea is harder to implement.