blob: 5046fd8aae6b3a308d7b1cbd5f9f4936299692b3 [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc52f43e2010-08-22 00:59:46 +00007//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// unique_ptr
13
14// Test unique_ptr move assignment
15
16#include <memory>
Dan Albert1d4a1ed2016-05-25 22:36:09 -070017#include <cassert>
Howard Hinnantc52f43e2010-08-22 00:59:46 +000018
19// Can't copy from const lvalue
20
Dan Albert1d4a1ed2016-05-25 22:36:09 -070021struct A
22{
23 static int count;
24 A() {++count;}
25 A(const A&) {++count;}
26 ~A() {--count;}
27};
28
29int A::count = 0;
30
Howard Hinnantc52f43e2010-08-22 00:59:46 +000031int main()
32{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070033 {
34 const std::unique_ptr<A> s(new A);
35 std::unique_ptr<A> s2;
36 s2 = s;
37 }
Howard Hinnantc52f43e2010-08-22 00:59:46 +000038}