Fwd: [PATCH][GSoC] Extend shared_ptr to support arrays
Mon Jun 15 02:23:00 GMT 2015
---------- Forwarded message ----------
From: Fan You <email@example.com>
Date: 2015-06-14 23:45 GMT+08:00
Subject: Re: [PATCH][GSoC] Extend shared_ptr to support arrays
To: Jonathan Wakely <firstname.lastname@example.org>
Cc: Tim Shen <email@example.com>, gcc-patches
<firstname.lastname@example.org>, libstdc++ <email@example.com>
This is the revised patch.
Bootstrapped and Tested on Darwin 10.9.4. with testsuite 20_util/*
__shared_ptr<libfund<_Tp>> : private __shared_ptr<std::remove_extent<_Tp>>
to prevent changing everything once __shared_ptr<_Tp> has changed.
2015-06-12 17:04 GMT+08:00 Jonathan Wakely <firstname.lastname@example.org>:
> On 11/06/15 23:43 -0700, Tim Shen wrote:
>> + using element_type = _Tp[N];
>> using element_type = typename std::remove_extent_t<_Tp>; ?
> Well at that point in the file we're inside the
> __shared_ptr<__libfund_v1<_Tp[N]> specialization, so it could be
> + using element_type = _Tp;
> However, if we combine some or all of the partial specializations into
> one, as I suggested, then it would become simply:
> using element_type = std::remove_extent_t<_Tp>;
> (Without the 'typename', although for this to work the new partial
> specializations need to be surrounded in #if __cplusplus >= 201402L,
> otherwise the remove_extent_t alias is no available.)
> This is a good example of why I think we should combine the very
> similar specializations, and then use helper traits to define the
> parts that vary depending on _Tp, instead of duplicating the entire
> class template.
>>> using _Deleter_type = typename conditional<is_array<_Tp>::value,
>>> _Normal_deleter, _Array_deleter>::type;
>> Sadly std::default_delete doesn't support _Tp[N]. It will also works
>> to create a std::default_delete-ish helper trait, with _Tp[N]
>> specialized to `delete ` as well.
> Another point I missed in my review is that 'N' is not a reserved
> identifier, it needs to be changed to _Nm or something else in the
> implementation namespace, so that it still works even if users do:
> #define N "Boom!" :-P
> #include <experimental/memory>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 29130 bytes
Desc: not available
More information about the Libstdc++