// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template class unique_ptr { T *ptr; unique_ptr(const unique_ptr&) = delete; // expected-note 3{{'unique_ptr' has been explicitly marked deleted here}} unique_ptr &operator=(const unique_ptr&) = delete; // expected-note{{candidate function has been explicitly deleted}} public: unique_ptr() : ptr(0) { } unique_ptr(unique_ptr &&other) : ptr(other.ptr) { other.ptr = 0; } explicit unique_ptr(T *ptr) : ptr(ptr) { } ~unique_ptr() { delete ptr; } unique_ptr &operator=(unique_ptr &&other) { // expected-note{{candidate function not viable: no known conversion from 'unique_ptr' to 'unique_ptr &&' for 1st argument}} if (this == &other) return *this; delete ptr; ptr = other.ptr; other.ptr = 0; return *this; } }; template struct remove_reference { typedef T type; }; template struct remove_reference { typedef T type; }; template struct remove_reference { typedef T type; }; template typename remove_reference::type&& move(T&& t) { return static_cast::type&&>(t); } template T&& forward(typename remove_reference::type& t) { return static_cast(t); } template T&& forward(typename remove_reference::type&& t) { return static_cast(t); } template unique_ptr make_unique_ptr(Args &&...args) { return unique_ptr(new T(forward(args)...)); } template void accept_unique_ptr(unique_ptr); // expected-note{{passing argument to parameter here}} unique_ptr test_unique_ptr() { // Simple construction unique_ptr p; unique_ptr p1(new int); // Move construction unique_ptr p2(make_unique_ptr(17)); unique_ptr p3 = make_unique_ptr(17); // Copy construction (failures) unique_ptr p4(p); // expected-error{{call to deleted constructor of 'unique_ptr'}} unique_ptr p5 = p; // expected-error{{call to deleted constructor of 'unique_ptr'}} // Move assignment p2 = move(p); p2 = make_unique_ptr(0); // Copy assignment (failures); p2 = p3; // expected-error{{overload resolution selected deleted operator '='}} // Implicit copies accept_unique_ptr(make_unique_ptr(0.0)); accept_unique_ptr(move(p2)); // Implicit copies (failures); accept_unique_ptr(p); // expected-error{{call to deleted constructor of 'unique_ptr'}} return p; } namespace perfect_forwarding { struct A { }; struct F0 { void operator()(A&, const A&, A&&, const A&&, A&&, const A&&); // expected-note{{candidate function not viable: 5th argument ('const perfect_forwarding::A') would lose const qualifier}} }; template void forward(F f, Args &&...args) { f(static_cast(args)...); // expected-error{{no matching function for call to object of type 'perfect_forwarding::F0'}} } template T get(); void test_forward() { forward(F0(), get(), get(), get(), get(), get(), get()); forward(F0(), get(), get(), get(), get(), // expected-note{{in instantiation of function template specialization 'perfect_forwarding::forward' requested here}} get(), get()); } };