blob: 7bd209339484153436d82de3849af834d2488cfb [file] [log] [blame]
Jason Merrill4b2e63de2014-03-07 15:01:12 -05001// { dg-do link { target c++11 } }
Russell Yanofsky8af2fec2007-05-31 01:18:22 +00002
Jason Merrille7f19302009-07-31 22:26:42 -04003template<typename _Tp>
4inline _Tp&&
5movel(_Tp& __t)
6{ return static_cast<_Tp&&>(__t); }
7
Russell Yanofsky8af2fec2007-05-31 01:18:22 +00008struct S {};
9struct T
10{
Jason Merrille7f19302009-07-31 22:26:42 -040011 T(S && s_) : s(movel(s_)) {}
12 S && get() { return movel(s); }
13 operator S&&() { return movel(s); }
Russell Yanofsky8af2fec2007-05-31 01:18:22 +000014 S && s;
Jason Merrill4757b072011-06-30 17:09:55 -040015 S s2;
Russell Yanofsky8af2fec2007-05-31 01:18:22 +000016};
17
18void named(S const &) {}
19void named(S&&);
20
21void unnamed(S const &);
22void unnamed(S&&) {}
23
24void f(S && p)
25{
Jason Merrille7f19302009-07-31 22:26:42 -040026 S && s(movel(p));
27 T t(movel(s));
Russell Yanofsky8af2fec2007-05-31 01:18:22 +000028
29 named(s); // variable reference
30 named(p); // parameter reference
31 named(t.s); // class member access
32
33 unnamed(t.get()); // function return
34 unnamed(t); // implicit conversion
35 unnamed(static_cast<S&&>(s)); // cast to rvalue
Jason Merrill4757b072011-06-30 17:09:55 -040036 unnamed(static_cast<T&&>(t).s2); // cast to rvalue
Russell Yanofsky8af2fec2007-05-31 01:18:22 +000037}
38
39int main()
40{
41}