Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Example Iterator Increment
#include <functional> #include <iostream> #include <vector> int acc(std::function<int(int, int)> func, std::vector<int> operands) { auto it = operands.begin(); int result = func(*it, *(++it)); if (operands.size() > 2) { for (++it; it!=operands.end(); ++it) { result = func(result, *it); } } return result; } int main() { std::cout << acc([](int a, int b){ return a+b; }, {3, 5, 2}) << std::endl; }
run
|
edit
|
history
|
help
0
Default_Template
Vector
Merge overlapping time intervals
thermal_containers
ugly quick sort
Dar
e-olymp.com---problem1590---Birthday 2
Pointer to class members
Test 16(2020)
How to access member function of a class using scope