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
aju
BinTree palyground
Zadanie Kalkulator z bajerami
The Menu
static_cast makes a copy
hack qus
Scemo
adjacent_difference-30-Seconds-Of-CPP
PointPattern
Spejmer