Skip to content

Commit

Permalink
[hcheng] 201604182225 combinet lamda with auto to implement max in macro
Browse files Browse the repository at this point in the history
  • Loading branch information
githubch committed Apr 18, 2016
1 parent 59bd976 commit d66f135
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions auto_sample/auto_applied_in_macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ int main(int argc, char ** argv){
int b = 3;
std::cout <<"Max(a, b)="<<Max(a,b)<<std::endl;
std::cout <<"3 * Max(a, b) should equal 9, and the result is "<<3*Max(a, b)<<std::endl;
auto result = [=](){ return 4 * Max(a, b);};
std::cout<<result()<<std::endl;
std::cout <<"4 * Max(2, 3) should equal 12, and the result is "<<[=](){return 4*Max(a,b);}()<<std::endl;
std::cout <<"5 * Max(2, 3) should equal 15, and the result is "<<[=]()->float{return 5*Max(a, b)*1.0;}()<<std::endl;
int m = 2;
int n = 3;
std::cout <<"Max_(m, n)="<<Max_(m++, n++)<<std::endl;
Expand Down

2 comments on commit d66f135

@githubch
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

@githubch
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

Please sign in to comment.