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