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// <memory>
11
12// unique_ptr
13
14// Test unique_ptr converting move ctor
15
16#include <memory>
17#include <utility>
18#include <cassert>
19
20#include "deleter_types.h"
21
22// test converting move ctor.  Should only require a MoveConstructible deleter, or if
23//    deleter is a reference, not even that.
24// Implicit version
25
26struct A
27{
28    static int count;
29    A() {++count;}
30    A(const A&) {++count;}
31    virtual ~A() {--count;}
32};
33
34int A::count = 0;
35
36struct B
37    : public A
38{
39    static int count;
40    B() {++count;}
41    B(const B&) {++count;}
42    virtual ~B() {--count;}
43};
44
45int B::count = 0;
46
47int main()
48{
49    std::unique_ptr<B, Deleter<B> > s(new B);
50    std::unique_ptr<A, Deleter<A> > s2 = s;
51}
52