Created on 2016-10-18.00:00:00 last changed 90 months ago
Proposed resolution:
This wording is relative to N4606.
Add to [diff.cpp14.utilities]:
[util.smartptr.shared]
Change: Different constraint on conversions from unique_ptr. Rationale: Adding array support to shared_ptr, via the syntax shared_ptr<T[]> and shared_ptr<T[N]>. Effect on original feature: Valid code may fail to compile or change meaning in this International Standard. For example:#include <memory> std::unique_ptr<int[]> arr(new int[1]); std::shared_ptr<int> ptr(std::move(arr)); // error: int(*)[] is not compatible with int*
[ 2016-11-12, Issaquah ]
Sat AM: Priority 0; move to Ready
This is valid in C++11 and C++14:
shared_ptr<int> s{unique_ptr<int[]>{new int[1]}};
The shared_ptr copies the default_delete<int[]> deleter from the unique_ptr, which does the right thing on destruction.
In C++17 it won't compile, because !is_convertible_v<int(*)[], int*>. The solution is to use shared_ptr<int[]>, which doesn't work well in C++14, so there's no transition path. This should be called out in Annex C.History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
2017-03-05 23:41:16 | admin | set | status: ready -> wp |
2016-11-21 05:09:01 | admin | set | messages: + msg8669 |
2016-11-21 05:09:01 | admin | set | status: new -> ready |
2016-10-31 20:29:21 | admin | set | messages: + msg8574 |
2016-10-18 00:00:00 | admin | create |