I need to sum up some vectors; that is, I want to sum the nth
elements of every vector and make a new vector with the result. (I've already ensured that the input vectors are all the same size.) I'd like to do this with the excellent range-v3 library. I've tried this:
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <map>
#include <range/v3/all.hpp>
int main()
{
std::cout << "Hello, Wandbox!" << std::endl;
std::vector< int > v1{ 1,1,1};
std::vector< int> v2{1,1,1};
auto va = ranges::view::zip( v1, v2 )
| ranges::view::transform(
[](auto&& tuple){ return ranges::accumulate( tuple, 0.0 ); }
);
}
I get the error that I can't call to ranges::accumulate
like this. I feel like this is a simple thing that I'm just not quite seeing.
Please advise
EDIT: I ask a follow-on question here: How to zip vector of vector with range-v3