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 assignment
15 
16 // Can't assign from lvalue
17 
18 #include <memory>
19 
20 #include "test_macros.h"
21 #include "../../deleter.h"
22 
23 struct A
24 {
AA25     A() {}
~AA26     virtual ~A() {}
27 };
28 
29 struct B : public A
30 {
31 };
32 
33 // Can't assign from lvalue
main()34 int main()
35 {
36     Deleter<B> db;
37     std::unique_ptr<B, Deleter<B>& > s(new B, db);
38     Deleter<A> da;
39     std::unique_ptr<A, Deleter<A> &> s2(new A, da);
40 #if TEST_STD_VER >= 11
41     s2 = s; // expected-error {{no viable overloaded '='}}
42 #else
43     // NOTE: The move-semantic emulation creates an ambiguous overload set
44     // so that assignment from an lvalue does not compile
45     s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}}
46 #endif
47 }
48