Hi, Here is the revised patch including all the test case.
This can also be seen at <https://github.com/Noeyfan/gcc-1> on branch <shared_arrays> Any comments? 2015-06-23 12:19 GMT+08:00 Tim Shen <tims...@google.com>: > On Sun, Jun 21, 2015 at 3:50 AM, Tim Shen <tims...@google.com> wrote: >> Quickly looked at __shared_ptr<__libfund_v1<_Tp>, _Lp>; will look at >> the rest parts later. > > All suggestions apply for all occursions, not just for the quoted code. > > + // helpers for std::experimental::enable_shared_from_this > + > + template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> > + struct __helper_for_experimental_enable_shared > + { > + void _Call_M_assign(__weak_ptr<__libfund_v1<_Tp>, _Lp>& __wp, > + _Tp* __ptr, > + const __shared_count<_Lp>& __refcount) > + { __wp._M_assign(__ptr, __refcount); } > + }; > Make the function it static; Suggested class name: __weak_ptr_friend, > function name _S_assign. > > + // Used by __enable_shared_from_this. > + void > + _M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept > + { > + _M_ptr = __ptr; > + _M_refcount = __refcount; > + } > element_type* __ptr? > > Also need a _Compatible; possible implementation: > > template<typename _From_type, typename _To_type> > struct __sp_compatible_helper > { static constexpr bool value = std::is_convertible<_From_type*, > _To_type*>::value; }; > > template<size_t _Nm, typename _Tp> > struct __sp_compatible_helper<_Tp[_Nm], _Tp[]> > { static constexpr bool value = true; }; > > ... > > template<typename _Tp1> > using _Compatible = typename std::enable_if<__sp_compatible<_Tp1, > _Tp>::value>::type; > > + template<typename _Tp1, typename _Tp2> > + inline bool > + operator<(const shared_ptr<_Tp1>& __a, > + const shared_ptr<_Tp2>& __b) noexcept > + { > + using _Tp1_RE = typename remove_extent<_Tp1>::type; > + using _Tp2_RE = typename remove_extent<_Tp2>::type; > + using _CT = typename std::common_type<_Tp1_RE*, _Tp2_RE*>::type; > + return std::less<_CT>()(__a.get(), __b.get()); > + } > using _Tp1_RE = typename shared_ptr<_Tp1>::element_type; > > + // 8.2.1.3, shared_ptr casts > + template<typename _Tp, typename _Tp1> > + inline shared_ptr<_Tp> > + static_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept > + { shared_ptr<_Tp>(__r, static_cast<typename > shared_ptr<_Tp>::element_type*>(__r.get())); } > + > Missing "return". You can turn on -Wsystem-headers to check for warnings. > > > -- > Regards, > Tim Shen
a
Description: Binary data