move_convert10.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 converting move ctor 15 16// test converting move ctor. Should only require a MoveConstructible deleter, or if 17// deleter is a reference, not even that. 18// implicit version 19 20#include <memory> 21#include <cassert> 22 23struct A 24{ 25 static int count; 26 A() {++count;} 27 A(const A&) {++count;} 28 virtual ~A() {--count;} 29}; 30 31int A::count = 0; 32 33struct B 34 : public A 35{ 36 static int count; 37 B() {++count;} 38 B(const B&) {++count;} 39 virtual ~B() {--count;} 40}; 41 42int B::count = 0; 43 44int main() 45{ 46 { 47 const std::unique_ptr<B[]> s(new B); 48 A* p = s.get(); 49 std::unique_ptr<A[]> s2 = s; 50 assert(s2.get() == p); 51 assert(s.get() == 0); 52 assert(A::count == 1); 53 assert(B::count == 1); 54 } 55 assert(A::count == 0); 56 assert(B::count == 0); 57} 58