Home | History | Annotate | Download | only in unique.ptr.single.asgn
      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 
     20 struct A
     21 {
     22     A() {}
     23     virtual ~A() {}
     24 };
     25 
     26 struct B : public A
     27 {
     28 };
     29 
     30 // Can't assign from lvalue
     31 int main()
     32 {
     33     std::unique_ptr<B> s;
     34     std::unique_ptr<A> s2;
     35 #if TEST_STD_VER >= 11
     36     s2 = s; // expected-error {{no viable overloaded '='}}
     37 #else
     38     // NOTE: The move-semantic emulation creates an ambiguous overload set
     39     // so that assignment from an lvalue does not compile
     40     s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}}
     41 #endif
     42 }
     43