move02.fail.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// unique_ptr
13
14// Test unique_ptr move ctor
15
16// test move ctor.  Can't copy from const lvalue
17
18#include <memory>
19#include <cassert>
20
21struct A
22{
23    static int count;
24    A() {++count;}
25    A(const A&) {++count;}
26    ~A() {--count;}
27};
28
29int A::count = 0;
30
31int main()
32{
33    {
34    const std::unique_ptr<A[]> s(new A[3]);
35    A* p = s.get();
36    std::unique_ptr<A[]> s2 = s;
37    assert(s2.get() == p);
38    assert(s.get() == 0);
39    assert(A::count == 1);
40    }
41    assert(A::count == 0);
42}
43