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 #include <memory> 17 18 #include "test_macros.h" 19 #include "../../deleter.h" 20 21 struct A 22 { 23 A() {} 24 virtual ~A() {} 25 }; 26 27 struct B : public A 28 { 29 }; 30 31 // Can't assign from lvalue 32 int main() 33 { 34 const std::unique_ptr<B> s(new B); 35 std::unique_ptr<A> s2; 36 #if TEST_STD_VER >= 11 37 s2 = s; // expected-error {{no viable overloaded '='}} 38 #else 39 // NOTE: The error says "constructor" because the assignment operator takes 40 // 's' by value and attempts to copy construct it. 41 s2 = s; // expected-error {{no matching constructor for initialization}} 42 #endif 43 } 44