forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pezy chen
committed
May 13, 2018
1 parent
db498da
commit 9cee9eb
Showing
4 changed files
with
77 additions
and
155 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <iostream> | ||
|
||
void f(int v1, int& v2) | ||
{ | ||
std::cout << v1 << " " << ++v2 << std::endl; | ||
} | ||
|
||
void g(int&& i, int& j) | ||
{ | ||
std::cout << i << " " << ++j << std::endl; | ||
} | ||
|
||
template <typename F, typename T1, typename T2> | ||
void flip(F f, T1&& t1, T2&& t2) | ||
{ | ||
f(std::forward<T2>(t2), std::forward<T1>(t1)); | ||
} | ||
|
||
int main() | ||
{ | ||
int j = 0; | ||
flip(f, j, 42); | ||
flip(g, j, 42); | ||
} |