This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH][GSoC] Extend shared_ptr to support arrays
- From: Tim Shen <timshen at google dot com>
- To: Fan You <youfan dot noey at gmail dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Sun, 21 Jun 2015 11:41:38 -0700
- Subject: Re: [PATCH][GSoC] Extend shared_ptr to support arrays
- Authentication-results: sourceware.org; auth=none
- References: <CALvpekGQvTp2zRz65cnP+Ex7TKHQygdrYkqo5nUKGJ3bLQj8ww at mail dot gmail dot com> <CAG4ZjNkEPsJd4Crx1xtp4ZvJ-xFGJ5aaR8qb+A7aVMi++wKRtw at mail dot gmail dot com> <20150612090414 dot GP12728 at redhat dot com> <CALvpekG4+YxSVz+jm_quo20=2bWYXnkBFrjDyBu6eYXW4YarHQ at mail dot gmail dot com> <20150615093829 dot GA21485 at redhat dot com> <CALvpekE2a8qi8qRjdzsDOi2OCRJw_ccYd1CrL6z68rLFW0fK0g at mail dot gmail dot com> <20150616132839 dot GA13009 at redhat dot com> <CALvpekFiRrz2UHTvGh+aqnkQPdL-Y=O-vRUXhxwVs-Wz+5v-RA at mail dot gmail dot com> <CAG4ZjNnyp7Tax3CU0BAnbR0DSo6Xc+z8S7+3BSkYSyPpUpyu6g at mail dot gmail dot com> <CALvpekEmLhme8=FnRRVX3afpU5LkWyrbsJBzW6S6bPUYtRP=gg at mail dot gmail dot com> <CALvpekF3MfgGxuQcPNc2k9eJ1ZWHOSngDu0OC+oBXnvQs6VzpA at mail dot gmail dot com>
On Sun, Jun 21, 2015 at 10:44 AM, Fan You <youfan.noey@gmail.com> wrote:
> passing the __lib_fund version should be fine here, since the
> __base_type will judg while doing _M_ptr = __r._M_prt.
This is correct only for now, but who knows what's gonna happen in the
future? Being more defensive and introduce less dependency (not let
shared_ptr depend on libfund_v1) is usually good.
>> Please be aware of spaces surrounding operators:
>> _GLIBCXX_DEBUG_ASSERT(get() != 0 && i >= 0);
>
> what does this mean?
Compare string "get() !=0" against "get() != 0", and " i>=0" against
"i >= 0", and see what you find :)
> Is it a good idea to change _Convertible alias to _Compatible in base.h?
>
> template <typename _Tp1>
> struct _is_compatible
> {
> bool value = (is_array<_Tp1>::value && is_array<_Tp>::value
> && (is_same<typename
> remove_extent<_Tp1>::type, element_type>::value))
> || (is_convertible<_Tp1, element_type*>::value);
> };
>
> template<typename _Tp1>
> using _Compatible
> = typename enable_if<_is_compatible<_Tp1>().value>::type;
"or Y is U[N] and T is U cv []", not vice versa. So:
std::experimental::shared_ptr<int[]> sp(new int[2]);
std::experimental::shared_ptr<int[2]> spa(sp);
...shouldn't compile. You probably need some specialization to do this.
_is_compatible -> __sp_is_compatible seems to be better.
--
Regards,
Tim Shen