// Without inline namespace: // // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp // RUN: cpp11-migrate -replace-auto_ptr %t.cpp -- -I %S/Inputs std=c++11 // RUN: FileCheck -input-file=%t.cpp %s // // With inline namespace: // // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp // RUN: cpp11-migrate -replace-auto_ptr %t.cpp -- -I %S/Inputs std=c++11 \ // RUN: -DUSE_INLINE_NAMESPACE=1 // RUN: FileCheck -input-file=%t.cpp %s #include "memory_stub.h" void takes_ownership_fn(std::auto_ptr x); // CHECK: void takes_ownership_fn(std::unique_ptr x); std::auto_ptr get_by_value(); // CHECK: std::unique_ptr get_by_value(); class Wrapper { public: std::auto_ptr &get_wrapped(); private: std::auto_ptr wrapped; }; void f() { std::auto_ptr a, b, c; // CHECK: std::unique_ptr a, b, c; Wrapper wrapper_a, wrapper_b; a = b; // CHECK: a = std::move(b); wrapper_a.get_wrapped() = wrapper_b.get_wrapped(); // CHECK: wrapper_a.get_wrapped() = std::move(wrapper_b.get_wrapped()); // Test that 'std::move()' is inserted when call to the // copy-constructor are made. takes_ownership_fn(c); // CHECK: takes_ownership_fn(std::move(c)); takes_ownership_fn(wrapper_a.get_wrapped()); // CHECK: takes_ownership_fn(std::move(wrapper_a.get_wrapped())); std::auto_ptr d[] = { std::auto_ptr(new int(1)), std::auto_ptr(new int(2)) }; std::auto_ptr e = d[0]; // CHECK: std::unique_ptr d[] = { std::unique_ptr(new int(1)), // CHECK-NEXT: std::unique_ptr(new int(2)) }; // CHECK-NEXT: std::unique_ptr e = std::move(d[0]); // Test that std::move() is not used when assigning an rvalue std::auto_ptr f; f = std::auto_ptr(new int(0)); // CHECK: std::unique_ptr f; // CHECK-NEXT: f = std::unique_ptr(new int(0)); std::auto_ptr g = get_by_value(); // CHECK: std::unique_ptr g = get_by_value(); }