move_only2.fail.cpp revision c52f43e72dfcea03037729649da84c23b3beb04a
1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===----------------------------------------------------------------------===//
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//                     The LLVM Compiler Infrastructure
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// License. See LICENSE.TXT for details.
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===----------------------------------------------------------------------===//
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// test move
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <utility>
137dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include <cassert>
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <typeinfo>
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <stdio.h>
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class move_only
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles){
20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifdef _LIBCPP_MOVE
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only(const move_only&);
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only& operator=(const move_only&);
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#else  // _LIBCPP_MOVE
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only(move_only&);
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only& operator=(move_only&);
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif  // _LIBCPP_MOVE
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)public:
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifdef _LIBCPP_MOVE
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only(move_only&&) {}
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only& operator=(move_only&&) {}
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#else  // _LIBCPP_MOVE
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only(std::__rv<move_only>) {}
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif  // _LIBCPP_MOVE
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only() {}
39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)move_only source() {return move_only();}
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)const move_only csource() {return move_only();}
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void test(move_only) {}
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)int main()
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles){
48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    move_only a;
49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const move_only ca = move_only();
50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    test(ca);
52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)