[cfe-commits] [libcxx] r111747 - in /libcxx/trunk: include/memory test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp

Howard Hinnant hhinnant at apple.com
Sat Aug 21 14:14:53 PDT 2010


Author: hhinnant
Date: Sat Aug 21 16:14:53 2010
New Revision: 111747

URL: http://llvm.org/viewvc/llvm-project?rev=111747&view=rev
Log:
US 108, N3109

Modified:
    libcxx/trunk/include/memory
    libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp

Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=111747&r1=111746&r2=111747&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Sat Aug 21 16:14:53 2010
@@ -218,8 +218,6 @@
     template <class U, class E>
         unique_ptr(unique_ptr<U, E>&& u);
     template <class U>
-        explicit unique_ptr(auto_ptr<U>& u);
-    template <class U>
         unique_ptr(auto_ptr<U>&& u);
 
     // destructor
@@ -2001,17 +1999,6 @@
                 "unique_ptr constructed with null function pointer deleter");
         }
 
-    template <class _Up>
-        _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(auto_ptr<_Up>& __p,
-                typename enable_if<
-                                      is_convertible<_Up*, _Tp*>::value &&
-                                      is_same<_Dp, default_delete<_Tp> >::value,
-                                      __nat
-                                  >::type = __nat())
-            : __ptr_(__p.release())
-            {
-            }
-
 #ifdef _LIBCPP_MOVE
     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional<
                                         is_reference<deleter_type>::value,
@@ -2695,8 +2682,6 @@
                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); 
 #ifdef _LIBCPP_MOVE    
     template<class _Yp> shared_ptr(auto_ptr<_Yp>&& __r); 
-#else
-    template<class _Yp> shared_ptr(auto_ptr<_Yp>& __r); 
 #endif
 #ifdef _LIBCPP_MOVE    
 private:
@@ -2722,7 +2707,7 @@
     template<class _Yp> shared_ptr& operator=(shared_ptr<_Yp>&& __r); 
     template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp>&& __r); 
 #else
-    template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp>& __r); 
+    template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp> __r); 
 #endif
 #ifdef _LIBCPP_MOVE    
 private:
@@ -3004,7 +2989,7 @@
 #ifdef _LIBCPP_MOVE    
 shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r)
 #else
-shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>& __r)
+shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r)
 #endif
     : __ptr_(__r.get())
 {

Modified: libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp?rev=111747&r1=111746&r2=111747&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp (original)
+++ libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp Sat Aug 21 16:14:53 2010
@@ -1 +1 @@
-//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <memory>

// unique_ptr

// Test unique_ptr(pointer) ctor

#include <memory>
#include <cassert>

// template <class U> explicit unique_ptr(auto_ptr<U>&);

struct A
{
    static int count;
    A() {++count;}
    A(const A&) {++count;}
    virtual ~A() {--count;}
};

int A::count = 0;

struct B
    : public A
{
    static int count;
    B() {++count;}
    B(const B&) {++count;}
    virtual ~B() {--count;}
};

int B::count = 0;

int main()
{
    {
    B* p = new B;
    std::auto_ptr<B> ap(p);
    std::unique_ptr<A> up(ap);
    assert(up.get() == p);
    assert(ap.get() == 0);
    assert(A::count == 1);
    assert(B::count == 1);
    }
    
 assert(A::count == 0);
    assert(B::count == 0);
    {
    B* p = new B;
    std::auto_ptr<B> ap(p);
    std::unique_ptr<A> up;
    up = ap;
    assert(up.get() == p);
    assert(ap.get() == 0);
    assert(A::count == 1);
    assert(B::count == 1);
    }
    assert(A::count == 0);
    assert(B::count == 0);
    {
    B* p = new B;
    std::auto_ptr<B> ap(p);
    std::unique_ptr<A> up;
    up = std::move(ap);
    assert(up.get() == p);
    assert(ap.get() == 0);
    assert(A::count == 1);
    assert(B::count == 1);
    }
    assert(A::count == 0);
    assert(B::count == 0);
}
\ No newline at end of file
+//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <memory>

// unique_ptr

// Test unique_ptr(pointer) ctor

#include <memory>
#include <cassert>

// template <class U> explicit unique_ptr(auto_ptr<U>&);

struct A
{
    static int count;
    A() {++count;}
    A(const A&) {++count;}
    virtual ~A() {--count;}
};

int A::count = 0;

struct B
    : public A
{
    static int count;
    B() {++count;}
    B(const B&) {++count;}
    virtual ~B() {--count;}
};

int B::count = 0;

int main()
{
    {
    B* p = new B;
    std::auto_ptr<B> ap(p);
    std::unique_ptr<A> up(std::move(ap));
    assert(up.get() == p);
    assert(ap.get() == 0);
    assert(A::count == 1);
    assert(B::count == 1);
 
    }
    assert(A::count == 0);
    assert(B::count == 0);
    {
    B* p = new B;
    std::auto_ptr<B> ap(p);
    std::unique_ptr<A> up;
    up = std::move(ap);
    assert(up.get() == p);
    assert(ap.get() == 0);
    assert(A::count == 1);
    assert(B::count == 1);
    }
    assert(A::count == 0);
    assert(B::count == 0);
}
\ No newline at end of file





More information about the cfe-commits mailing list