OSDN Git Service

/cp
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / iop.C
1 // I, Howard Hinnant, hereby place this code in the public domain.
2
3 // Test that the implicit object parameter is *not* an rvalue reference, but is instead
4 //   identical to that specified in C++03.  That is, the implicit object parameter is
5 //   an lvalue reference that can bind to an rvalue. :-\
6 //   See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html under the
7 //   section "Revision 1 Summary and Rationale" for more details.
8
9 // { dg-do compile }
10 // { dg-options "-std=c++0x" }
11
12 template <bool> struct sa;
13 template <> struct sa<true> {};
14
15 struct one   {char x[1];};
16 struct two   {char x[2];};
17
18 struct os
19 {
20     one operator<<(int);
21 };
22
23 struct A
24 {
25     A(int);
26 };
27
28 two operator<<(os&, const A&);
29
30 void test()
31 {
32     os o;
33     sa<sizeof(o << 1) == 1> t1;  // Calls os::operator<<(int)
34                                  // Would be ambiguous if the implicit object parameter
35                                  // was an rvalue reference.
36 }
37
38 int main()
39 {
40     return 0;
41 }