move_only1.fail.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// test move
11
12#include <utility>
13#include <cassert>
14
15#include <typeinfo>
16#include <stdio.h>
17
18class move_only
19{
20#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
21    move_only(const move_only&);
22    move_only& operator=(const move_only&);
23#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
24    move_only(move_only&);
25    move_only& operator=(move_only&);
26#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
27
28public:
29
30#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
31    move_only(move_only&&) {}
32    move_only& operator=(move_only&&) {}
33#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
34    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
35    move_only(std::__rv<move_only>) {}
36#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
37
38    move_only() {}
39};
40
41move_only source() {return move_only();}
42const move_only csource() {return move_only();}
43
44void test(move_only) {}
45
46int main()
47{
48    move_only a;
49    const move_only ca = move_only();
50
51    test(a);
52}
53