Algorithm for function evaluation by pairs (C++, STL)
问题 I need to apply a custom func to an STL containers by pairs -> that is: // if c => {a,b,c,d,e,f,g}; // a,b,c,.. are just aliases for some object my_algorithm(c.begin(),c.end(),[](auto a, auto b){ a + b }); // c++14 should resolve into something like this: temp1 = a + b; temp2 = c + d; temp3 = e + f; temp4 = temp1 + temp2; temp5 = temp3 + g; result = temp4 + temp5; (I am sure this kind of algorithm has a proper name but I have no idea what this may be) I have tried with std::accumulate , I am