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
Example of range-base for loop
MenuStream
C++ Car Racing game framework 2
pangram
Precendence of Pointer Indirection Example
Print All Paths In Matrix
Chinu
te lo paso
1
Stream4