Skip to content

Commit 1f5cd53

Browse files
author
wintel2014
committed
Left Or Right reference
1 parent ae70e4d commit 1f5cd53

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
#include <utility>
3+
4+
void foo(int&)
5+
{
6+
std::cout<<"Left Reference\n";
7+
}
8+
9+
void foo(int&&)
10+
{
11+
std::cout<<"Right Reference\n";
12+
}
13+
14+
int bar()
15+
{
16+
return 123;
17+
}
18+
19+
int main()
20+
{
21+
int&& r = 123;
22+
int i=123;
23+
foo(r);
24+
foo(bar());
25+
26+
foo(std::forward<decltype(bar())>(r));
27+
foo(std::forward<decltype(r)>(r));
28+
foo(std::forward<decltype(i)>(r));
29+
foo(std::forward<decltype(i)>(i));
30+
foo(std::forward<int&>(i));
31+
foo(std::forward<int>(i));
32+
}

0 commit comments

Comments
 (0)