This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3 PATCH] Implement N4089 and N4387
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 7 Aug 2015 09:35:57 +0100
- Subject: Re: [v3 PATCH] Implement N4089 and N4387
- Authentication-results: sourceware.org; auth=none
- References: <CAFk2RUZtfiKHsz49_JLB6t5YW+X0qxQkCib85XrXAw2ANU5puA at mail dot gmail dot com> <CAFk2RUa5GdmzMFdVwVFkF__zj5iaa8hfmUUq0quFkhFSQX5djw at mail dot gmail dot com> <CAFk2RUYMneAAc9=cbVyn9P9n0w8+L+cguWrbSffU0Do=a8sVwA at mail dot gmail dot com> <CAFk2RUYTKT9O1ZFQTi6a9M+5gCcxQiarnHoOhg1DfYEdOs2cSA at mail dot gmail dot com>
On 20/07/15 00:28 +0300, Ville Voutilainen wrote:
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&& __u)): Constrain with deleter
You can save some space by not including the parameter name __u here,
and similarly in other entries.
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&& __u)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up __p)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up __p,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type __d)): Likewise.
(unique_ptr(_Up __p, typename
remove_reference<deleter_type>::type&& __d)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&& __u)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&& __u)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up __p)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t p)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
You've lost the 'noexcept' on the unique_ptr<T[]> unary constructor:
explicit
- unique_ptr(pointer __p) noexcept
+ unique_ptr(_Up __p)
Also missing 'noexcept' here:
- // Disable resetting from convertible pointer types.
- template<typename _Up, typename = _Require<is_pointer<pointer>,
- is_convertible<_Up*, pointer>, __is_derived_Tp<_Up>>>
- void reset(_Up*) = delete;
+ void reset(nullptr_t p = nullptr)
+ {
+ reset(pointer());
+ }
and the parameter 'p' there is not a reserved name, but isn't used so
should be removed anyway.
OK for trunk with those minor items fixed.