Skip to content

Commit 4727272

Browse files
committedApr 16, 2017
Overhaul unique_ptr - Implement LWG 2801, 2905, 2520.
This patch overhauls both specializations of unique_ptr while implementing the following LWG issues: * LWG 2801 - This issue constrains unique_ptr's constructors when the deleter type is not default constructible. Additionally it adds SFINAE conditions to unique_ptr<T[]>::unique_ptr(Up). * LWG 2905 - This issue reworks the unique_ptr(pointer, /* see below */ deleter) constructors so that they correctly SFINAE when the deleter argument cannot be used to construct the stored deleter. * LWG 2520 - This issue fixes initializing unique_ptr<T[]> from nullptr. Libc++ had previously implemented this issue, but the suggested resolution still broke initialization from NULL. This patch re-works the unique_ptr<T[]>(Up, deleter) overloads so that they accept NULL as well as nullptr. llvm-svn: 300406
1 parent 9edfb08 commit 4727272

19 files changed

+1278
-428
lines changed
 

‎libcxx/include/memory

+526-351
Large diffs are not rendered by default.

‎libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,32 @@ void test_sfinae() {
8282
static_assert(!std::is_assignable<U, U&>::value, "");
8383
static_assert(!std::is_assignable<U, const U&>::value, "");
8484
static_assert(!std::is_assignable<U, const U&&>::value, "");
85-
static_assert(std::is_assignable<U, U&&>::value, "");
85+
static_assert(std::is_nothrow_assignable<U, U&&>::value, "");
8686
}
8787
{
8888
typedef std::unique_ptr<VT, GenericDeleter> U;
8989
static_assert(!std::is_assignable<U, U&>::value, "");
9090
static_assert(!std::is_assignable<U, const U&>::value, "");
9191
static_assert(!std::is_assignable<U, const U&&>::value, "");
92-
static_assert(std::is_assignable<U, U&&>::value, "");
92+
static_assert(std::is_nothrow_assignable<U, U&&>::value, "");
9393
}
9494
{
9595
typedef std::unique_ptr<VT, NCDeleter<VT>&> U;
9696
static_assert(!std::is_assignable<U, U&>::value, "");
9797
static_assert(!std::is_assignable<U, const U&>::value, "");
9898
static_assert(!std::is_assignable<U, const U&&>::value, "");
99-
static_assert(std::is_assignable<U, U&&>::value, "");
99+
static_assert(std::is_nothrow_assignable<U, U&&>::value, "");
100100
}
101101
{
102102
typedef std::unique_ptr<VT, const NCDeleter<VT>&> U;
103103
static_assert(!std::is_assignable<U, U&>::value, "");
104104
static_assert(!std::is_assignable<U, const U&>::value, "");
105105
static_assert(!std::is_assignable<U, const U&&>::value, "");
106-
static_assert(std::is_assignable<U, U&&>::value, "");
106+
static_assert(std::is_nothrow_assignable<U, U&&>::value, "");
107107
}
108108
}
109109

110+
110111
int main() {
111112
{
112113
test_basic</*IsArray*/ false>();

0 commit comments

Comments
 (0)
Please sign in to comment.