Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
Please
log in
to post a comment.
Pierwiastkowanie
compute power to a number manually, and by using function.
CPP - Arrays - Ex.4
Policy based smart pointer
Complex Number Class
1068 - Investigation
string match
begin_end.cpp
C++ - Chained Methods
std::string(pid_t)
stackse - search stackoverflow differently
Please log in to post a comment.