Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C

raw
1 // I, Howard Hinnant, hereby place this code in the public domain.
2
3 // Test: Unamed rvalue references are treated as lvalues.
4
5 // { dg-do compile { target c++11 } }
6
7 template <bool> struct sa;
8 template <> struct sa<true> {};
9
10 struct one {long x[1];};
11 struct two {long x[2];};
12
13 struct A {};
14
15 one foo(const A&) {return one();}
16 two foo(A&&) {return two();}
17
18 template<typename _Tp>
19 inline _Tp&&
20 movel(_Tp& __t)
21 { return static_cast<_Tp&&>(__t); }
22
23 A&& source() {static A a; return movel(a);}
24
25 int test1()
26 {
27 sa<sizeof(foo(source())) == 2 * sizeof(long)> t1;
28 return 0;
29 }
30
31 int main()
32 {
33 return test1();
34 }