Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <memory> |
| 11 | |
| 12 | // unique_ptr |
| 13 | |
| 14 | // Test unique_ptr move assignment |
| 15 | |
| 16 | #include <memory> |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 17 | #include <cassert> |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 18 | |
| 19 | // Can't copy from lvalue |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 20 | |
| 21 | struct A |
| 22 | { |
| 23 | static int count; |
| 24 | A() {++count;} |
| 25 | A(const A&) {++count;} |
| 26 | ~A() {--count;} |
| 27 | }; |
| 28 | |
| 29 | int A::count = 0; |
| 30 | |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 31 | int main() |
| 32 | { |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 33 | { |
| 34 | std::unique_ptr<A> s(new A); |
| 35 | std::unique_ptr<A> s2; |
| 36 | s2 = s; |
| 37 | } |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 38 | } |