[libcxx-commits] [libcxx] r368885 - This commit removes std::shared_ptr::make_shared and std::shared_ptr::allocate_shared as they are not part of the standard. This commit also adds the helper function "__create_with_cntrl_block" which std::allocate_shared and std::make_shared have been updated to use.

Zoe Carver via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 14 10:34:57 PDT 2019


My bad Nico. I think I looked at that doc a while ago but forgot the
guidelines. I will make sure my next commit message has shorter lines, that
it has a title/body, and that it follows the other guidelines. Thanks for
letting me know.

On Wed, Aug 14, 2019 at 10:31 AM Nico Weber <thakis at chromium.org> wrote:

> Hi Zoe,
>
> could you try to keep commit message line length a bit shorter? It's
> optional, but nice for folks who look at `git log` in the terminal. See
> also https://llvm.org/docs/DeveloperPolicy.html#commit-messages
>
> Thanks,
> Nico
>
> On Wed, Aug 14, 2019 at 1:18 PM Zoe Carver via libcxx-commits <
> libcxx-commits at lists.llvm.org> wrote:
>
>> Author: zoecarver
>> Date: Wed Aug 14 10:19:25 2019
>> New Revision: 368885
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=368885&view=rev
>> Log:
>> This commit removes std::shared_ptr::make_shared and
>> std::shared_ptr::allocate_shared as they are not part of the standard. This
>> commit also adds the helper function "__create_with_cntrl_block" which
>> std::allocate_shared and std::make_shared have been updated to use.
>>
>> Modified:
>>     libcxx/trunk/include/memory
>>
>> Modified: libcxx/trunk/include/memory
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=368885&r1=368884&r2=368885&view=diff
>>
>> ==============================================================================
>> --- libcxx/trunk/include/memory (original)
>> +++ libcxx/trunk/include/memory Wed Aug 14 10:19:25 2019
>> @@ -3831,48 +3831,16 @@ public:
>>                        : nullptr);}
>>  #endif  // _LIBCPP_NO_RTTI
>>
>> -#ifndef _LIBCPP_HAS_NO_VARIADICS
>> -
>> -    template<class ..._Args>
>> -        static
>> -        shared_ptr<_Tp>
>> -        make_shared(_Args&& ...__args);
>> -
>> -    template<class _Alloc, class ..._Args>
>> -        static
>> -        shared_ptr<_Tp>
>> -        allocate_shared(const _Alloc& __a, _Args&& ...__args);
>> -
>> -#else  // _LIBCPP_HAS_NO_VARIADICS
>> -
>> -    static shared_ptr<_Tp> make_shared();
>> -
>> -    template<class _A0>
>> -        static shared_ptr<_Tp> make_shared(_A0&);
>> -
>> -    template<class _A0, class _A1>
>> -        static shared_ptr<_Tp> make_shared(_A0&, _A1&);
>> -
>> -    template<class _A0, class _A1, class _A2>
>> -        static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&);
>> -
>> -    template<class _Alloc>
>> -        static shared_ptr<_Tp>
>> -        allocate_shared(const _Alloc& __a);
>> -
>> -    template<class _Alloc, class _A0>
>> -        static shared_ptr<_Tp>
>> -        allocate_shared(const _Alloc& __a, _A0& __a0);
>> -
>> -    template<class _Alloc, class _A0, class _A1>
>> -        static shared_ptr<_Tp>
>> -        allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1);
>> -
>> -    template<class _Alloc, class _A0, class _A1, class _A2>
>> -        static shared_ptr<_Tp>
>> -        allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2&
>> __a2);
>> -
>> -#endif  // _LIBCPP_HAS_NO_VARIADICS
>> +    template<class _Yp, class _CntrlBlk>
>> +    static shared_ptr<_Tp>
>> +    __create_with_cntrl_block(_Yp* __p, _CntrlBlk* __cntrl)
>> +    {
>> +        shared_ptr<_Tp> __r;
>> +        __r.__ptr_ = __p;
>> +        __r.__cntrl_ = __cntrl;
>> +        __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> +        return __r;
>> +    }
>>
>>  private:
>>      template <class _Yp, bool = is_function<_Yp>::value>
>> @@ -4186,206 +4154,6 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_
>>      __r.release();
>>  }
>>
>> -#ifndef _LIBCPP_HAS_NO_VARIADICS
>> -
>> -template<class _Tp>
>> -template<class ..._Args>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::make_shared(_Args&& ...__args)
>> -{
>> -    static_assert( is_constructible<_Tp, _Args...>::value, "Can't
>> construct object in make_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> -    typedef allocator<_CntrlBlk> _A2;
>> -    typedef __allocator_destructor<_A2> _D2;
>> -    _A2 __a2;
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
>> -    ::new(__hold2.get()) _CntrlBlk(__a2,
>> _VSTD::forward<_Args>(__args)...);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = __hold2.release();
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _Alloc, class ..._Args>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
>> -{
>> -    static_assert( is_constructible<_Tp, _Args...>::value, "Can't
>> construct object in allocate_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> -    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _A2;
>> -    typedef __allocator_destructor<_A2> _D2;
>> -    _A2 __a2(__a);
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
>> -    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> -        _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -#else  // _LIBCPP_HAS_NO_VARIADICS
>> -
>> -template<class _Tp>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::make_shared()
>> -{
>> -    static_assert((is_constructible<_Tp>::value), "Can't construct
>> object in make_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> -    typedef allocator<_CntrlBlk> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2;
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(__hold2.get()) _CntrlBlk(__alloc2);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = __hold2.release();
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _A0>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::make_shared(_A0& __a0)
>> -{
>> -    static_assert((is_constructible<_Tp, _A0>::value), "Can't construct
>> object in make_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> -    typedef allocator<_CntrlBlk> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2;
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = __hold2.release();
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _A0, class _A1>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1)
>> -{
>> -    static_assert((is_constructible<_Tp, _A0, _A1>::value), "Can't
>> construct object in make_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> -    typedef allocator<_CntrlBlk> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2;
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = __hold2.release();
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _A0, class _A1, class _A2>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
>> -{
>> -    static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't
>> construct object in make_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> -    typedef allocator<_CntrlBlk> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2;
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = __hold2.release();
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _Alloc>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::allocate_shared(const _Alloc& __a)
>> -{
>> -    static_assert((is_constructible<_Tp>::value), "Can't construct
>> object in allocate_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> -    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2(__a);
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> -        _CntrlBlk(__a);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _Alloc, class _A0>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0)
>> -{
>> -    static_assert((is_constructible<_Tp, _A0>::value), "Can't construct
>> object in allocate_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> -    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2(__a);
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> -        _CntrlBlk(__a, __a0);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _Alloc, class _A0, class _A1>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
>> -{
>> -    static_assert((is_constructible<_Tp, _A0, _A1>::value), "Can't
>> construct object in allocate_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> -    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2(__a);
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> -        _CntrlBlk(__a, __a0, __a1);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -template<class _Tp>
>> -template<class _Alloc, class _A0, class _A1, class _A2>
>> -shared_ptr<_Tp>
>> -shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1&
>> __a1, _A2& __a2)
>> -{
>> -    static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't
>> construct object in allocate_shared" );
>> -    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> -    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> -    typedef __allocator_destructor<_Alloc2> _D2;
>> -    _Alloc2 __alloc2(__a);
>> -    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> -    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> -        _CntrlBlk(__a, __a0, __a1, __a2);
>> -    shared_ptr<_Tp> __r;
>> -    __r.__ptr_ = __hold2.get()->get();
>> -    __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
>> -    __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
>> -    return __r;
>> -}
>> -
>> -#endif  // _LIBCPP_HAS_NO_VARIADICS
>> -
>>  template<class _Tp>
>>  shared_ptr<_Tp>::~shared_ptr()
>>  {
>> @@ -4578,7 +4346,17 @@ typename enable_if
>>  >::type
>>  make_shared(_Args&& ...__args)
>>  {
>> -    return
>> shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
>> +    static_assert(is_constructible<_Tp, _Args...>::value, "Can't
>> construct object in make_shared");
>> +    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> +    typedef allocator<_CntrlBlk> _A2;
>> +    typedef __allocator_destructor<_A2> _D2;
>> +
>> +    _A2 __a2;
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
>> +    ::new(__hold2.get()) _CntrlBlk(__a2,
>> _VSTD::forward<_Args>(__args)...);
>> +
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +                                                      __hold2.release());
>>  }
>>
>>  template<class _Tp, class _Alloc, class ..._Args>
>> @@ -4590,73 +4368,145 @@ typename enable_if
>>  >::type
>>  allocate_shared(const _Alloc& __a, _Args&& ...__args)
>>  {
>> -    return shared_ptr<_Tp>::allocate_shared(__a,
>> _VSTD::forward<_Args>(__args)...);
>> +    static_assert(is_constructible<_Tp, _Args...>::value, "Can't
>> construct object in allocate_shared");
>> +
>> +    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> +    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _A2;
>> +    typedef __allocator_destructor<_A2> _D2;
>> +
>> +    _A2 __a2(__a);
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
>> +    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> +        _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
>> +
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +
>> _VSTD::addressof(*__hold2.release()));
>>  }
>>
>>  #else  // _LIBCPP_HAS_NO_VARIADICS
>>
>>  template<class _Tp>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  make_shared()
>>  {
>> -    return shared_ptr<_Tp>::make_shared();
>> +    static_assert((is_constructible<_Tp>::value), "Can't construct
>> object in make_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> +    typedef allocator<_CntrlBlk> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2;
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(__hold2.get()) _CntrlBlk(__alloc2);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +                                                      __hold2.release());
>>  }
>>
>>  template<class _Tp, class _A0>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  make_shared(_A0& __a0)
>>  {
>> -    return shared_ptr<_Tp>::make_shared(__a0);
>> +    static_assert((is_constructible<_Tp, _A0>::value), "Can't construct
>> object in make_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> +    typedef allocator<_CntrlBlk> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2;
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +                                                      __hold2.release());
>>  }
>>
>>  template<class _Tp, class _A0, class _A1>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  make_shared(_A0& __a0, _A1& __a1)
>>  {
>> -    return shared_ptr<_Tp>::make_shared(__a0, __a1);
>> +    static_assert((is_constructible<_Tp, _A0, _A1>::value), "Can't
>> construct object in make_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> +    typedef allocator<_CntrlBlk> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2;
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +                                                      __hold2.release());
>>  }
>>
>>  template<class _Tp, class _A0, class _A1, class _A2>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
>>  {
>> -    return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2);
>> +    static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't
>> construct object in make_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
>> +    typedef allocator<_CntrlBlk> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2;
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +                                                      __hold2.release());
>>  }
>>
>>  template<class _Tp, class _Alloc>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  allocate_shared(const _Alloc& __a)
>>  {
>> -    return shared_ptr<_Tp>::allocate_shared(__a);
>> +    static_assert((is_constructible<_Tp>::value), "Can't construct
>> object in allocate_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> +    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2(__a);
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> +        _CntrlBlk(__a);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +
>> _VSTD::addressof(*__hold2.release()));
>>  }
>>
>>  template<class _Tp, class _Alloc, class _A0>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  allocate_shared(const _Alloc& __a, _A0& __a0)
>>  {
>> -    return shared_ptr<_Tp>::allocate_shared(__a, __a0);
>> +    static_assert((is_constructible<_Tp, _A0>::value), "Can't construct
>> object in allocate_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> +    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2(__a);
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> +        _CntrlBlk(__a, __a0);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +
>> _VSTD::addressof(*__hold2.release()));
>>  }
>>
>>  template<class _Tp, class _Alloc, class _A0, class _A1>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
>>  {
>> -    return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1);
>> +    static_assert((is_constructible<_Tp, _A0, _A1>::value), "Can't
>> construct object in allocate_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> +    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2(__a);
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> +        _CntrlBlk(__a, __a0, __a1);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +
>> _VSTD::addressof(*__hold2.release()));
>>  }
>>
>>  template<class _Tp, class _Alloc, class _A0, class _A1, class _A2>
>> -inline _LIBCPP_INLINE_VISIBILITY
>>  shared_ptr<_Tp>
>>  allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2)
>>  {
>> -    return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2);
>> +    static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't
>> construct object in allocate_shared" );
>> +    typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
>> +    typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type
>> _Alloc2;
>> +    typedef __allocator_destructor<_Alloc2> _D2;
>> +    _Alloc2 __alloc2(__a);
>> +    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1),
>> _D2(__alloc2, 1));
>> +    ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
>> +        _CntrlBlk(__a, __a0, __a1, __a2);
>> +    return
>> shared_ptr<_Tp>::__create_with_cntrl_block(__hold2.get()->get(),
>> +
>> _VSTD::addressof(*__hold2.release()));
>>  }
>>
>>  #endif  // _LIBCPP_HAS_NO_VARIADICS
>>
>>
>> _______________________________________________
>> libcxx-commits mailing list
>> libcxx-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190814/e6515676/attachment-0001.html>


More information about the libcxx-commits mailing list