Created
June 16, 2011 19:39
-
-
Save dfm/1030052 to your computer and use it in GitHub Desktop.
dude.. gist it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double any_op(double, double, std::function<double(double,double)>); | |
int main() | |
{ | |
std::function<double(double,double)> add = [](double a, double b) -> double { return a+b; }; | |
std::function<double(double,double)> sub = [](double a, double b) -> double { return a-b; }; | |
printf("5 + 10 = %0.2f\n", any_op(5., 10., add)); | |
printf("5 - 10 = %0.2f\n", any_op(5., 10., sub)); | |
return 0; | |
} | |
double any_op(double a, double b, std::function<double(double,double)> op) { | |
return op(a,b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment