US 108, N3109
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@111747 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a785e4e469
commit
92172b891f
@ -217,8 +217,6 @@ public:
|
||||
unique_ptr(nullptr_t) : unique_ptr() { }
|
||||
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);
|
||||
|
||||
@ -2001,17 +1999,6 @@ public:
|
||||
"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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ template<class _Yp>
|
||||
#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())
|
||||
{
|
||||
|
@ -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);
}
|
||||
//===----------------------------------------------------------------------===//
//
// 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);
}
|
Loading…
x
Reference in New Issue
Block a user