| OLD | NEW |
| 1 // -*- C++ -*- | 1 // -*- C++ -*- |
| 2 //===-------------------------- memory ------------------------------------===// | 2 //===-------------------------- memory ------------------------------------===// |
| 3 // | 3 // |
| 4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
| 5 // | 5 // |
| 6 // This file is dual licensed under the MIT and the University of Illinois Open | 6 // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 // Source Licenses. See LICENSE.TXT for details. | 7 // Source Licenses. See LICENSE.TXT for details. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 | 10 |
| (...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 template <class _Traits, class _Tp> | 1693 template <class _Traits, class _Tp> |
| 1694 struct __rebind_alloc_helper | 1694 struct __rebind_alloc_helper |
| 1695 { | 1695 { |
| 1696 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 1696 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES |
| 1697 typedef typename _Traits::template rebind_alloc<_Tp> type; | 1697 typedef typename _Traits::template rebind_alloc<_Tp> type; |
| 1698 #else | 1698 #else |
| 1699 typedef typename _Traits::template rebind_alloc<_Tp>::other type; | 1699 typedef typename _Traits::template rebind_alloc<_Tp>::other type; |
| 1700 #endif | 1700 #endif |
| 1701 }; | 1701 }; |
| 1702 | 1702 |
| 1703 // allocation_counter |
| 1704 |
| 1705 struct allocation_counter |
| 1706 { |
| 1707 struct value |
| 1708 { |
| 1709 size_t total_usable_size; |
| 1710 size_t total_size; |
| 1711 size_t total_payload_size; |
| 1712 size_t total_count; |
| 1713 size_t total_constructed_size; |
| 1714 }; |
| 1715 |
| 1716 static value get(allocation_group group); |
| 1717 static void allocated(allocation_group group, const void* ptr, size_t size,
size_t payload_size); |
| 1718 static void deallocated(allocation_group group, const void* ptr, size_t size
, size_t payload_size); |
| 1719 |
| 1720 static void constructed(allocation_group group, size_t size); |
| 1721 static void destroyed(allocation_group group, size_t size); |
| 1722 }; |
| 1723 |
| 1703 // allocator | 1724 // allocator |
| 1704 | 1725 |
| 1705 template <class _Tp> | 1726 template <class _Tp> |
| 1706 class _LIBCPP_TYPE_VIS_ONLY allocator | 1727 class _LIBCPP_TYPE_VIS_ONLY allocator |
| 1707 { | 1728 { |
| 1708 public: | 1729 public: |
| 1709 typedef size_t size_type; | 1730 typedef size_t size_type; |
| 1710 typedef ptrdiff_t difference_type; | 1731 typedef ptrdiff_t difference_type; |
| 1711 typedef _Tp* pointer; | 1732 typedef _Tp* pointer; |
| 1712 typedef const _Tp* const_pointer; | 1733 typedef const _Tp* const_pointer; |
| 1713 typedef _Tp& reference; | 1734 typedef _Tp& reference; |
| 1714 typedef const _Tp& const_reference; | 1735 typedef const _Tp& const_reference; |
| 1715 typedef _Tp value_type; | 1736 typedef _Tp value_type; |
| 1716 | 1737 |
| 1717 typedef true_type propagate_on_container_move_assignment; | 1738 typedef true_type propagate_on_container_move_assignment; |
| 1718 typedef true_type is_always_equal; | 1739 typedef true_type is_always_equal; |
| 1719 | 1740 |
| 1720 template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 1741 template <class _Up> struct rebind {typedef allocator<_Up> other;}; |
| 1721 | 1742 |
| 1722 _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} | 1743 _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} |
| 1723 template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up
>&) _NOEXCEPT {} | 1744 template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up
>&) _NOEXCEPT {} |
| 1724 _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT | 1745 _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT |
| 1725 {return _VSTD::addressof(__x);} | 1746 {return _VSTD::addressof(__x);} |
| 1726 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _
NOEXCEPT | 1747 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _
NOEXCEPT |
| 1727 {return _VSTD::addressof(__x);} | 1748 {return _VSTD::addressof(__x);} |
| 1728 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::c
onst_pointer = 0) | 1749 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::c
onst_pointer = 0) |
| 1729 {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));} | 1750 { |
| 1730 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT | 1751 allocation_group group = allocation_group::allocator; |
| 1731 {_VSTD::__deallocate((void*)__p);} | 1752 pointer __p = static_cast<pointer>(::operator new(__n * sizeof(_Tp), {ge
t_allocation_group_name(group)})); |
| 1753 allocation_counter::allocated(group, __p, __n * sizeof(_Tp), 0); |
| 1754 return __p; |
| 1755 } |
| 1756 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXC
EPT |
| 1757 { |
| 1758 allocation_counter::deallocated(allocation_group::allocator, __p, __n *
sizeof(_Tp), 0); |
| 1759 ::operator delete((void*)__p); |
| 1760 } |
| 1732 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | 1761 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT |
| 1733 {return size_type(~0) / sizeof(_Tp);} | 1762 {return size_type(~0) / sizeof(_Tp);} |
| 1734 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIAD
ICS) | 1763 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIAD
ICS) |
| 1735 template <class _Up, class... _Args> | 1764 template <class _Up, class... _Args> |
| 1736 _LIBCPP_INLINE_VISIBILITY | 1765 _LIBCPP_INLINE_VISIBILITY |
| 1737 void | 1766 void |
| 1738 construct(_Up* __p, _Args&&... __args) | 1767 construct(_Up* __p, _Args&&... __args) |
| 1739 { | 1768 { |
| 1740 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); | 1769 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); |
| 1741 } | 1770 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 typedef true_type propagate_on_container_move_assignment; | 1839 typedef true_type propagate_on_container_move_assignment; |
| 1811 typedef true_type is_always_equal; | 1840 typedef true_type is_always_equal; |
| 1812 | 1841 |
| 1813 template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 1842 template <class _Up> struct rebind {typedef allocator<_Up> other;}; |
| 1814 | 1843 |
| 1815 _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} | 1844 _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} |
| 1816 template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up
>&) _NOEXCEPT {} | 1845 template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up
>&) _NOEXCEPT {} |
| 1817 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _
NOEXCEPT | 1846 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _
NOEXCEPT |
| 1818 {return _VSTD::addressof(__x);} | 1847 {return _VSTD::addressof(__x);} |
| 1819 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::c
onst_pointer = 0) | 1848 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::c
onst_pointer = 0) |
| 1820 {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));} | 1849 { |
| 1821 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT | 1850 allocation_group group = allocation_group::allocator; |
| 1822 {_VSTD::__deallocate((void*)__p);} | 1851 pointer __p = static_cast<pointer>(::operator new(__n * sizeof(_Tp), {ge
t_allocation_group_name(group)})); |
| 1852 allocation_counter::allocated(group, __p, __n * sizeof(_Tp), 0); |
| 1853 return __p; |
| 1854 } |
| 1855 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXC
EPT |
| 1856 { |
| 1857 allocation_counter::deallocated(allocation_group::allocator, __p, __n *
sizeof(_Tp), 0); |
| 1858 ::operator delete((void*)__p); |
| 1859 } |
| 1823 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | 1860 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT |
| 1824 {return size_type(~0) / sizeof(_Tp);} | 1861 {return size_type(~0) / sizeof(_Tp);} |
| 1825 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIAD
ICS) | 1862 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIAD
ICS) |
| 1826 template <class _Up, class... _Args> | 1863 template <class _Up, class... _Args> |
| 1827 _LIBCPP_INLINE_VISIBILITY | 1864 _LIBCPP_INLINE_VISIBILITY |
| 1828 void | 1865 void |
| 1829 construct(_Up* __p, _Args&&... __args) | 1866 construct(_Up* __p, _Args&&... __args) |
| 1830 { | 1867 { |
| 1831 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); | 1868 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); |
| 1832 } | 1869 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 _LIBCPP_INLINE_VISIBILITY | 1916 _LIBCPP_INLINE_VISIBILITY |
| 1880 void | 1917 void |
| 1881 construct(pointer __p, const _A0& __a0, const _A1& __a1) | 1918 construct(pointer __p, const _A0& __a0, const _A1& __a1) |
| 1882 { | 1919 { |
| 1883 ::new((void*)__p) _Tp(__a0, __a1); | 1920 ::new((void*)__p) _Tp(__a0, __a1); |
| 1884 } | 1921 } |
| 1885 #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO
_VARIADICS) | 1922 #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO
_VARIADICS) |
| 1886 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} | 1923 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} |
| 1887 }; | 1924 }; |
| 1888 | 1925 |
| 1926 // counting_allocator |
| 1927 |
| 1928 struct zero_allocation_payload {}; |
| 1929 |
| 1930 template <class Payload> |
| 1931 constexpr size_t get_allocation_payload_size() { return sizeof(Payload); } |
| 1932 |
| 1933 template <> |
| 1934 constexpr size_t get_allocation_payload_size<zero_allocation_payload>() { return
0; } |
| 1935 |
| 1936 template <class T, allocation_group Group, class Payload> |
| 1937 class _LIBCPP_TYPE_VIS_ONLY counting_allocator: public allocator<T> |
| 1938 { |
| 1939 typedef allocator<T> base; |
| 1940 |
| 1941 constexpr static size_t payload_size() |
| 1942 { |
| 1943 constexpr size_t size = get_allocation_payload_size<Payload>(); |
| 1944 static_assert(sizeof(T) >= size, "payload is too big"); |
| 1945 return size; |
| 1946 } |
| 1947 |
| 1948 public: |
| 1949 constexpr static allocation_group group = Group; |
| 1950 using payload_type = Payload; |
| 1951 |
| 1952 using typename base::size_type; |
| 1953 using typename base::difference_type; |
| 1954 using typename base::pointer; |
| 1955 using typename base::const_pointer; |
| 1956 using typename base::reference; |
| 1957 using typename base::const_reference; |
| 1958 using typename base::value_type; |
| 1959 using typename base::propagate_on_container_move_assignment; |
| 1960 |
| 1961 template <class Other> |
| 1962 struct rebind |
| 1963 { |
| 1964 using other = counting_allocator<Other, Group, zero_allocation_payload>; |
| 1965 }; |
| 1966 |
| 1967 _LIBCPP_INLINE_VISIBILITY counting_allocator() _NOEXCEPT {} |
| 1968 |
| 1969 template <class Other, allocation_group OtherGroup, class OtherPayload> |
| 1970 _LIBCPP_INLINE_VISIBILITY counting_allocator( |
| 1971 const counting_allocator<Other, OtherGroup, OtherPayload>&) _NOEXCEPT {} |
| 1972 |
| 1973 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type n, allocator<void>::con
st_pointer = 0) |
| 1974 { |
| 1975 pointer ptr = static_cast<pointer>(::operator new(n * sizeof(T), {get_al
location_group_name(Group)})); |
| 1976 allocation_counter::allocated(Group, ptr, sizeof(T) * n, payload_size()
* n); |
| 1977 return ptr; |
| 1978 } |
| 1979 |
| 1980 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer ptr, size_type n) _NOEXCEP
T |
| 1981 { |
| 1982 allocation_counter::deallocated(Group, ptr, sizeof(T) * n, payload_size(
) * n); |
| 1983 _VSTD::__deallocate((void*)ptr); |
| 1984 } |
| 1985 |
| 1986 template <class Other, class... Args> |
| 1987 _LIBCPP_INLINE_VISIBILITY void construct(Other* ptr, Args&&... args) |
| 1988 { |
| 1989 static_assert(sizeof(Other) <= sizeof(T), "object is too big"); |
| 1990 allocation_counter::constructed(Group, sizeof(Other)); |
| 1991 ::new((void*)ptr) Other(_VSTD::forward<Args>(args)...); |
| 1992 } |
| 1993 |
| 1994 template <class Other> |
| 1995 _LIBCPP_INLINE_VISIBILITY void destroy(Other* ptr) |
| 1996 { |
| 1997 allocation_counter::destroyed(Group, sizeof(Other)); |
| 1998 ptr->~Other(); |
| 1999 } |
| 2000 |
| 2001 using base::address; |
| 2002 using base::max_size; |
| 2003 }; |
| 2004 |
| 2005 template <class Traits, class U, bool KeepPayload = true, allocation_group UGrou
p = allocation_group::invalid_group> |
| 2006 struct __rebind_counting_alloc_helper |
| 2007 { |
| 2008 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES |
| 2009 typedef typename Traits::template rebind_alloc<U> type; |
| 2010 #else |
| 2011 typedef typename Traits::template rebind_alloc<U>::other type; |
| 2012 #endif |
| 2013 }; |
| 2014 |
| 2015 template <class T, allocation_group TGroup, class Payload, class U> |
| 2016 struct __rebind_counting_alloc_helper<allocator_traits<counting_allocator<T, TGr
oup, Payload>>, U, true, allocation_group::invalid_group> |
| 2017 { |
| 2018 typedef counting_allocator<U, TGroup, Payload> type; |
| 2019 }; |
| 2020 |
| 2021 template <class T, allocation_group TGroup, class Payload, class U> |
| 2022 struct __rebind_counting_alloc_helper<allocator_traits<counting_allocator<T, TGr
oup, Payload>>, U, false, allocation_group::invalid_group> |
| 2023 { |
| 2024 typedef counting_allocator<U, TGroup, zero_allocation_payload> type; |
| 2025 }; |
| 2026 |
| 2027 template <class T, allocation_group TGroup, class Payload, class U, allocation_g
roup UGroup> |
| 2028 struct __rebind_counting_alloc_helper<allocator_traits<counting_allocator<T, TGr
oup, Payload>>, U, false, UGroup> |
| 2029 { |
| 2030 typedef counting_allocator<U, UGroup, zero_allocation_payload> type; |
| 2031 }; |
| 2032 |
| 2033 template <class Alloc> |
| 2034 void __count_destroyed(const Alloc&, size_t n) {} |
| 2035 |
| 2036 template <class T, allocation_group Group, class Payload> |
| 2037 void __count_destroyed(const counting_allocator<T, Group, Payload>&, size_t n) { |
| 2038 allocation_counter::destroyed(Group, sizeof(T) * n); |
| 2039 } |
| 2040 |
| 2041 template <class Alloc> |
| 2042 void __count_constructed(const Alloc&, size_t n) {} |
| 2043 |
| 2044 template <class T, allocation_group Group, class Payload> |
| 2045 void __count_constructed(const counting_allocator<T, Group, Payload>&, size_t n)
{ |
| 2046 allocation_counter::constructed(Group, sizeof(T) * n); |
| 2047 } |
| 2048 |
| 2049 // ^ counting_allocator |
| 2050 |
| 1889 template <class _Tp, class _Up> | 2051 template <class _Tp, class _Up> |
| 1890 inline _LIBCPP_INLINE_VISIBILITY | 2052 inline _LIBCPP_INLINE_VISIBILITY |
| 1891 bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return
true;} | 2053 bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return
true;} |
| 1892 | 2054 |
| 1893 template <class _Tp, class _Up> | 2055 template <class _Tp, class _Up> |
| 1894 inline _LIBCPP_INLINE_VISIBILITY | 2056 inline _LIBCPP_INLINE_VISIBILITY |
| 1895 bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return
false;} | 2057 bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return
false;} |
| 1896 | 2058 |
| 1897 template <class _OutputIterator, class _Tp> | 2059 template <class _OutputIterator, class _Tp> |
| 1898 class _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator | 2060 class _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator |
| (...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3749 __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; | 3911 __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; |
| 3750 public: | 3912 public: |
| 3751 _LIBCPP_INLINE_VISIBILITY | 3913 _LIBCPP_INLINE_VISIBILITY |
| 3752 __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) | 3914 __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) |
| 3753 : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::mo
ve(__a)) {} | 3915 : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::mo
ve(__a)) {} |
| 3754 | 3916 |
| 3755 #ifndef _LIBCPP_NO_RTTI | 3917 #ifndef _LIBCPP_NO_RTTI |
| 3756 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; | 3918 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; |
| 3757 #endif | 3919 #endif |
| 3758 | 3920 |
| 3921 _LIBCPP_INLINE_VISIBILITY |
| 3922 static __shared_ptr_pointer* __make(_Tp __p, _Dp __d = _Dp(), _Alloc __a = _
Alloc()) |
| 3923 { |
| 3924 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>
, __shared_ptr_pointer>::type _A2; |
| 3925 typedef __allocator_destructor<_A2> _D2; |
| 3926 _A2 _a2(__a); |
| 3927 unique_ptr<__shared_ptr_pointer, _D2> __hold2(_a2.allocate(1), _D2(_a2,
1)); |
| 3928 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) |
| 3929 __shared_ptr_pointer(_VSTD::move(__p), _VSTD::move(__d), _VSTD::move
(__a)); |
| 3930 return _VSTD::addressof(*__hold2.release()); |
| 3931 } |
| 3932 |
| 3759 private: | 3933 private: |
| 3760 virtual void __on_zero_shared() _NOEXCEPT; | 3934 virtual void __on_zero_shared() _NOEXCEPT; |
| 3761 virtual void __on_zero_shared_weak() _NOEXCEPT; | 3935 virtual void __on_zero_shared_weak() _NOEXCEPT; |
| 3762 }; | 3936 }; |
| 3763 | 3937 |
| 3764 #ifndef _LIBCPP_NO_RTTI | 3938 #ifndef _LIBCPP_NO_RTTI |
| 3765 | 3939 |
| 3766 template <class _Tp, class _Dp, class _Alloc> | 3940 template <class _Tp, class _Dp, class _Alloc> |
| 3767 const void* | 3941 const void* |
| 3768 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) cons
t _NOEXCEPT | 3942 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) cons
t _NOEXCEPT |
| 3769 { | 3943 { |
| 3770 return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0; | 3944 return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0; |
| 3771 } | 3945 } |
| 3772 | 3946 |
| 3773 #endif // _LIBCPP_NO_RTTI | 3947 #endif // _LIBCPP_NO_RTTI |
| 3774 | 3948 |
| 3775 template <class _Tp, class _Dp, class _Alloc> | 3949 template <class _Tp, class _Dp, class _Alloc> |
| 3776 void | 3950 void |
| 3777 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT | 3951 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT |
| 3778 { | 3952 { |
| 3779 __data_.first().second()(__data_.first().first()); | 3953 __data_.first().second()(__data_.first().first()); |
| 3780 __data_.first().second().~_Dp(); | 3954 __data_.first().second().~_Dp(); |
| 3781 } | 3955 } |
| 3782 | 3956 |
| 3783 template <class _Tp, class _Dp, class _Alloc> | 3957 template <class _Tp, class _Dp, class _Alloc> |
| 3784 void | 3958 void |
| 3785 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT | 3959 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT |
| 3786 { | 3960 { |
| 3787 typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::ty
pe _Al; | 3961 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, __
shared_ptr_pointer>::type _Al; |
| 3788 typedef allocator_traits<_Al> _ATraits; | 3962 typedef allocator_traits<_Al> _ATraits; |
| 3789 typedef pointer_traits<typename _ATraits::pointer> _PTraits; | 3963 typedef pointer_traits<typename _ATraits::pointer> _PTraits; |
| 3790 | 3964 |
| 3791 _Al __a(__data_.second()); | 3965 _Al __a(__data_.second()); |
| 3792 __data_.second().~_Alloc(); | 3966 __data_.second().~_Alloc(); |
| 3793 __a.deallocate(_PTraits::pointer_to(*this), 1); | 3967 __a.deallocate(_PTraits::pointer_to(*this), 1); |
| 3794 } | 3968 } |
| 3795 | 3969 |
| 3796 template <class _Tp, class _Alloc> | 3970 template <class _Tp, class _Alloc> |
| 3797 class __shared_ptr_emplace | 3971 class __shared_ptr_emplace |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3846 void | 4020 void |
| 3847 __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT | 4021 __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT |
| 3848 { | 4022 { |
| 3849 __data_.second().~_Tp(); | 4023 __data_.second().~_Tp(); |
| 3850 } | 4024 } |
| 3851 | 4025 |
| 3852 template <class _Tp, class _Alloc> | 4026 template <class _Tp, class _Alloc> |
| 3853 void | 4027 void |
| 3854 __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT | 4028 __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT |
| 3855 { | 4029 { |
| 3856 typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::ty
pe _Al; | 4030 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, __
shared_ptr_emplace>::type _Al; |
| 3857 typedef allocator_traits<_Al> _ATraits; | 4031 typedef allocator_traits<_Al> _ATraits; |
| 3858 typedef pointer_traits<typename _ATraits::pointer> _PTraits; | 4032 typedef pointer_traits<typename _ATraits::pointer> _PTraits; |
| 3859 _Al __a(__data_.first()); | 4033 _Al __a(__data_.first()); |
| 3860 __data_.first().~_Alloc(); | 4034 __data_.first().~_Alloc(); |
| 3861 __a.deallocate(_PTraits::pointer_to(*this), 1); | 4035 __a.deallocate(_PTraits::pointer_to(*this), 1); |
| 3862 } | 4036 } |
| 3863 | 4037 |
| 3864 template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; | 4038 template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; |
| 3865 | 4039 |
| 3866 template<class _Tp> | 4040 template<class _Tp> |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4158 { | 4332 { |
| 4159 } | 4333 } |
| 4160 | 4334 |
| 4161 template<class _Tp> | 4335 template<class _Tp> |
| 4162 template<class _Yp> | 4336 template<class _Yp> |
| 4163 shared_ptr<_Tp>::shared_ptr(_Yp* __p, | 4337 shared_ptr<_Tp>::shared_ptr(_Yp* __p, |
| 4164 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) | 4338 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) |
| 4165 : __ptr_(__p) | 4339 : __ptr_(__p) |
| 4166 { | 4340 { |
| 4167 unique_ptr<_Yp> __hold(__p); | 4341 unique_ptr<_Yp> __hold(__p); |
| 4168 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _Cn
trlBlk; | 4342 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, counting_allocator<_
Yp*, allocation_group::shared_ptr> > _CntrlBlk; |
| 4169 __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); | 4343 __cntrl_ = _CntrlBlk::__make(__p); |
| 4170 __hold.release(); | 4344 __hold.release(); |
| 4171 __enable_weak_this(__p); | 4345 __enable_weak_this(__p); |
| 4172 } | 4346 } |
| 4173 | 4347 |
| 4174 template<class _Tp> | 4348 template<class _Tp> |
| 4175 template<class _Yp, class _Dp> | 4349 template<class _Yp, class _Dp> |
| 4176 shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, | 4350 shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, |
| 4177 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) | 4351 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) |
| 4178 : __ptr_(__p) | 4352 : __ptr_(__p) |
| 4179 { | 4353 { |
| 4180 #ifndef _LIBCPP_NO_EXCEPTIONS | 4354 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4181 try | 4355 try |
| 4182 { | 4356 { |
| 4183 #endif // _LIBCPP_NO_EXCEPTIONS | 4357 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4184 typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 4358 typedef __shared_ptr_pointer<_Yp*, _Dp, counting_allocator<_Yp*, allocat
ion_group::shared_ptr> > _CntrlBlk; |
| 4185 __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); | 4359 __cntrl_ = _CntrlBlk::__make(__p, __d); |
| 4186 __enable_weak_this(__p); | 4360 __enable_weak_this(__p); |
| 4187 #ifndef _LIBCPP_NO_EXCEPTIONS | 4361 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4188 } | 4362 } |
| 4189 catch (...) | 4363 catch (...) |
| 4190 { | 4364 { |
| 4191 __d(__p); | 4365 __d(__p); |
| 4192 throw; | 4366 throw; |
| 4193 } | 4367 } |
| 4194 #endif // _LIBCPP_NO_EXCEPTIONS | 4368 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4195 } | 4369 } |
| 4196 | 4370 |
| 4197 template<class _Tp> | 4371 template<class _Tp> |
| 4198 template<class _Dp> | 4372 template<class _Dp> |
| 4199 shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) | 4373 shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) |
| 4200 : __ptr_(0) | 4374 : __ptr_(0) |
| 4201 { | 4375 { |
| 4202 #ifndef _LIBCPP_NO_EXCEPTIONS | 4376 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4203 try | 4377 try |
| 4204 { | 4378 { |
| 4205 #endif // _LIBCPP_NO_EXCEPTIONS | 4379 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4206 typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; | 4380 typedef __shared_ptr_pointer<nullptr_t, _Dp, counting_allocator<_Tp*, al
location_group::shared_ptr> > _CntrlBlk; |
| 4207 __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); | 4381 __cntrl_ = _CntrlBlk::__make(__p, __d); |
| 4208 #ifndef _LIBCPP_NO_EXCEPTIONS | 4382 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4209 } | 4383 } |
| 4210 catch (...) | 4384 catch (...) |
| 4211 { | 4385 { |
| 4212 __d(__p); | 4386 __d(__p); |
| 4213 throw; | 4387 throw; |
| 4214 } | 4388 } |
| 4215 #endif // _LIBCPP_NO_EXCEPTIONS | 4389 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4216 } | 4390 } |
| 4217 | 4391 |
| 4218 template<class _Tp> | 4392 template<class _Tp> |
| 4219 template<class _Yp, class _Dp, class _Alloc> | 4393 template<class _Yp, class _Dp, class _Alloc> |
| 4220 shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, | 4394 shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, |
| 4221 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) | 4395 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) |
| 4222 : __ptr_(__p) | 4396 : __ptr_(__p) |
| 4223 { | 4397 { |
| 4224 #ifndef _LIBCPP_NO_EXCEPTIONS | 4398 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4225 try | 4399 try |
| 4226 { | 4400 { |
| 4227 #endif // _LIBCPP_NO_EXCEPTIONS | 4401 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4228 typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; | 4402 typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; |
| 4229 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | 4403 __cntrl_ = _CntrlBlk::__make(__p, __d, __a); |
| 4230 typedef __allocator_destructor<_A2> _D2; | |
| 4231 _A2 __a2(__a); | |
| 4232 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | |
| 4233 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | |
| 4234 _CntrlBlk(__p, __d, __a); | |
| 4235 __cntrl_ = _VSTD::addressof(*__hold2.release()); | |
| 4236 __enable_weak_this(__p); | 4404 __enable_weak_this(__p); |
| 4237 #ifndef _LIBCPP_NO_EXCEPTIONS | 4405 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4238 } | 4406 } |
| 4239 catch (...) | 4407 catch (...) |
| 4240 { | 4408 { |
| 4241 __d(__p); | 4409 __d(__p); |
| 4242 throw; | 4410 throw; |
| 4243 } | 4411 } |
| 4244 #endif // _LIBCPP_NO_EXCEPTIONS | 4412 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4245 } | 4413 } |
| 4246 | 4414 |
| 4247 template<class _Tp> | 4415 template<class _Tp> |
| 4248 template<class _Dp, class _Alloc> | 4416 template<class _Dp, class _Alloc> |
| 4249 shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) | 4417 shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) |
| 4250 : __ptr_(0) | 4418 : __ptr_(0) |
| 4251 { | 4419 { |
| 4252 #ifndef _LIBCPP_NO_EXCEPTIONS | 4420 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4253 try | 4421 try |
| 4254 { | 4422 { |
| 4255 #endif // _LIBCPP_NO_EXCEPTIONS | 4423 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4256 typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; | 4424 typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; |
| 4257 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | 4425 __cntrl_ = _CntrlBlk::__make(__p, __d, __a); |
| 4258 typedef __allocator_destructor<_A2> _D2; | |
| 4259 _A2 __a2(__a); | |
| 4260 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | |
| 4261 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | |
| 4262 _CntrlBlk(__p, __d, __a); | |
| 4263 __cntrl_ = _VSTD::addressof(*__hold2.release()); | |
| 4264 #ifndef _LIBCPP_NO_EXCEPTIONS | 4426 #ifndef _LIBCPP_NO_EXCEPTIONS |
| 4265 } | 4427 } |
| 4266 catch (...) | 4428 catch (...) |
| 4267 { | 4429 { |
| 4268 __d(__p); | 4430 __d(__p); |
| 4269 throw; | 4431 throw; |
| 4270 } | 4432 } |
| 4271 #endif // _LIBCPP_NO_EXCEPTIONS | 4433 #endif // _LIBCPP_NO_EXCEPTIONS |
| 4272 } | 4434 } |
| 4273 | 4435 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4335 template<class _Tp> | 4497 template<class _Tp> |
| 4336 template<class _Yp> | 4498 template<class _Yp> |
| 4337 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 4499 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 4338 shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r, | 4500 shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r, |
| 4339 #else | 4501 #else |
| 4340 shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r, | 4502 shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r, |
| 4341 #endif | 4503 #endif |
| 4342 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) | 4504 typename enable_if<is_convertible<_Yp*, element_type
*>::value, __nat>::type) |
| 4343 : __ptr_(__r.get()) | 4505 : __ptr_(__r.get()) |
| 4344 { | 4506 { |
| 4345 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _Cn
trlBlk; | 4507 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, counting_allocator<_
Yp*, allocation_group::shared_ptr> > _CntrlBlk; |
| 4346 __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>())
; | 4508 __cntrl_ = _CntrlBlk::__make(__r.get()); |
| 4347 __enable_weak_this(__r.get()); | 4509 __enable_weak_this(__r.get()); |
| 4348 __r.release(); | 4510 __r.release(); |
| 4349 } | 4511 } |
| 4350 | 4512 |
| 4351 template<class _Tp> | 4513 template<class _Tp> |
| 4352 template <class _Yp, class _Dp> | 4514 template <class _Yp, class _Dp> |
| 4353 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 4515 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 4354 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 4516 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, |
| 4355 #else | 4517 #else |
| 4356 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 4518 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, |
| 4357 #endif | 4519 #endif |
| 4358 typename enable_if | 4520 typename enable_if |
| 4359 < | 4521 < |
| 4360 !is_lvalue_reference<_Dp>::value && | 4522 !is_lvalue_reference<_Dp>::value && |
| 4361 !is_array<_Yp>::value && | 4523 !is_array<_Yp>::value && |
| 4362 is_convertible<typename unique_ptr<_Yp, _Dp>::po
inter, element_type*>::value, | 4524 is_convertible<typename unique_ptr<_Yp, _Dp>::po
inter, element_type*>::value, |
| 4363 __nat | 4525 __nat |
| 4364 >::type) | 4526 >::type) |
| 4365 : __ptr_(__r.get()) | 4527 : __ptr_(__r.get()) |
| 4366 { | 4528 { |
| 4367 #if _LIBCPP_STD_VER > 11 | 4529 #if _LIBCPP_STD_VER > 11 |
| 4368 if (__ptr_ == nullptr) | 4530 if (__ptr_ == nullptr) |
| 4369 __cntrl_ = nullptr; | 4531 __cntrl_ = nullptr; |
| 4370 else | 4532 else |
| 4371 #endif | 4533 #endif |
| 4372 { | 4534 { |
| 4373 typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 4535 typedef __shared_ptr_pointer<_Yp*, _Dp, counting_allocator<_Yp*, allocat
ion_group::shared_ptr> > _CntrlBlk; |
| 4374 __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>())
; | 4536 __cntrl_ = _CntrlBlk::__make(__r.get(), __r.get_deleter()); |
| 4375 __enable_weak_this(__r.get()); | 4537 __enable_weak_this(__r.get()); |
| 4376 } | 4538 } |
| 4377 __r.release(); | 4539 __r.release(); |
| 4378 } | 4540 } |
| 4379 | 4541 |
| 4380 template<class _Tp> | 4542 template<class _Tp> |
| 4381 template <class _Yp, class _Dp> | 4543 template <class _Yp, class _Dp> |
| 4382 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 4544 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 4383 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 4545 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, |
| 4384 #else | 4546 #else |
| 4385 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 4547 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, |
| 4386 #endif | 4548 #endif |
| 4387 typename enable_if | 4549 typename enable_if |
| 4388 < | 4550 < |
| 4389 is_lvalue_reference<_Dp>::value && | 4551 is_lvalue_reference<_Dp>::value && |
| 4390 !is_array<_Yp>::value && | 4552 !is_array<_Yp>::value && |
| 4391 is_convertible<typename unique_ptr<_Yp, _Dp>::po
inter, element_type*>::value, | 4553 is_convertible<typename unique_ptr<_Yp, _Dp>::po
inter, element_type*>::value, |
| 4392 __nat | 4554 __nat |
| 4393 >::type) | 4555 >::type) |
| 4394 : __ptr_(__r.get()) | 4556 : __ptr_(__r.get()) |
| 4395 { | 4557 { |
| 4396 #if _LIBCPP_STD_VER > 11 | 4558 #if _LIBCPP_STD_VER > 11 |
| 4397 if (__ptr_ == nullptr) | 4559 if (__ptr_ == nullptr) |
| 4398 __cntrl_ = nullptr; | 4560 __cntrl_ = nullptr; |
| 4399 else | 4561 else |
| 4400 #endif | 4562 #endif |
| 4401 { | 4563 { |
| 4402 typedef __shared_ptr_pointer<_Yp*, | 4564 typedef __shared_ptr_pointer<_Yp*, |
| 4403 reference_wrapper<typename remove_reference
<_Dp>::type>, | 4565 reference_wrapper<typename remove_reference
<_Dp>::type>, |
| 4404 allocator<_Yp> > _CntrlBlk; | 4566 counting_allocator<_Yp*, allocation_group::
shared_ptr> > _CntrlBlk; |
| 4405 __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Y
p>()); | 4567 __cntrl_ = _CntrlBlk::__make(__r.get(), ref(__r.get_deleter())); |
| 4406 __enable_weak_this(__r.get()); | 4568 __enable_weak_this(__r.get()); |
| 4407 } | 4569 } |
| 4408 __r.release(); | 4570 __r.release(); |
| 4409 } | 4571 } |
| 4410 | 4572 |
| 4411 #ifndef _LIBCPP_HAS_NO_VARIADICS | 4573 #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 4412 | 4574 |
| 4413 template<class _Tp> | 4575 template<class _Tp> |
| 4414 template<class ..._Args> | 4576 template<class ..._Args> |
| 4415 shared_ptr<_Tp> | 4577 shared_ptr<_Tp> |
| 4416 shared_ptr<_Tp>::make_shared(_Args&& ...__args) | 4578 shared_ptr<_Tp>::make_shared(_Args&& ...__args) |
| 4417 { | 4579 { |
| 4418 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 4580 typedef counting_allocator<_Tp, allocation_group::shared_ptr> _Alloc; |
| 4419 typedef allocator<_CntrlBlk> _A2; | 4581 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4582 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _A2; |
| 4420 typedef __allocator_destructor<_A2> _D2; | 4583 typedef __allocator_destructor<_A2> _D2; |
| 4421 _A2 __a2; | 4584 _A2 __a2; |
| 4422 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 4585 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); |
| 4423 ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); | 4586 ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); |
| 4424 shared_ptr<_Tp> __r; | 4587 shared_ptr<_Tp> __r; |
| 4425 __r.__ptr_ = __hold2.get()->get(); | 4588 __r.__ptr_ = __hold2.get()->get(); |
| 4426 __r.__cntrl_ = __hold2.release(); | 4589 __r.__cntrl_ = __hold2.release(); |
| 4427 __r.__enable_weak_this(__r.__ptr_); | 4590 __r.__enable_weak_this(__r.__ptr_); |
| 4428 return __r; | 4591 return __r; |
| 4429 } | 4592 } |
| 4430 | 4593 |
| 4431 template<class _Tp> | 4594 template<class _Tp> |
| 4432 template<class _Alloc, class ..._Args> | 4595 template<class _Alloc, class ..._Args> |
| 4433 shared_ptr<_Tp> | 4596 shared_ptr<_Tp> |
| 4434 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) | 4597 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) |
| 4435 { | 4598 { |
| 4436 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 4599 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4437 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | 4600 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _A2; |
| 4438 typedef __allocator_destructor<_A2> _D2; | 4601 typedef __allocator_destructor<_A2> _D2; |
| 4439 _A2 __a2(__a); | 4602 _A2 __a2(__a); |
| 4440 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 4603 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); |
| 4441 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | 4604 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) |
| 4442 _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); | 4605 _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); |
| 4443 shared_ptr<_Tp> __r; | 4606 shared_ptr<_Tp> __r; |
| 4444 __r.__ptr_ = __hold2.get()->get(); | 4607 __r.__ptr_ = __hold2.get()->get(); |
| 4445 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); | 4608 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); |
| 4446 __r.__enable_weak_this(__r.__ptr_); | 4609 __r.__enable_weak_this(__r.__ptr_); |
| 4447 return __r; | 4610 return __r; |
| 4448 } | 4611 } |
| 4449 | 4612 |
| 4450 #else // _LIBCPP_HAS_NO_VARIADICS | 4613 #else // _LIBCPP_HAS_NO_VARIADICS |
| 4451 | 4614 |
| 4452 template<class _Tp> | 4615 template<class _Tp> |
| 4453 shared_ptr<_Tp> | 4616 shared_ptr<_Tp> |
| 4454 shared_ptr<_Tp>::make_shared() | 4617 shared_ptr<_Tp>::make_shared() |
| 4455 { | 4618 { |
| 4456 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 4619 typedef counting_allocator<_Tp, allocation_group::shared_ptr> _Alloc; |
| 4457 typedef allocator<_CntrlBlk> _Alloc2; | 4620 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4621 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4458 typedef __allocator_destructor<_Alloc2> _D2; | 4622 typedef __allocator_destructor<_Alloc2> _D2; |
| 4459 _Alloc2 __alloc2; | 4623 _Alloc2 __alloc2; |
| 4460 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4624 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4461 ::new(__hold2.get()) _CntrlBlk(__alloc2); | 4625 ::new(__hold2.get()) _CntrlBlk(__alloc2); |
| 4462 shared_ptr<_Tp> __r; | 4626 shared_ptr<_Tp> __r; |
| 4463 __r.__ptr_ = __hold2.get()->get(); | 4627 __r.__ptr_ = __hold2.get()->get(); |
| 4464 __r.__cntrl_ = __hold2.release(); | 4628 __r.__cntrl_ = __hold2.release(); |
| 4465 __r.__enable_weak_this(__r.__ptr_); | 4629 __r.__enable_weak_this(__r.__ptr_); |
| 4466 return __r; | 4630 return __r; |
| 4467 } | 4631 } |
| 4468 | 4632 |
| 4469 template<class _Tp> | 4633 template<class _Tp> |
| 4470 template<class _A0> | 4634 template<class _A0> |
| 4471 shared_ptr<_Tp> | 4635 shared_ptr<_Tp> |
| 4472 shared_ptr<_Tp>::make_shared(_A0& __a0) | 4636 shared_ptr<_Tp>::make_shared(_A0& __a0) |
| 4473 { | 4637 { |
| 4474 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 4638 typedef counting_allocator<_Tp, allocation_group::shared_ptr> _Alloc; |
| 4475 typedef allocator<_CntrlBlk> _Alloc2; | 4639 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4640 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4476 typedef __allocator_destructor<_Alloc2> _D2; | 4641 typedef __allocator_destructor<_Alloc2> _D2; |
| 4477 _Alloc2 __alloc2; | 4642 _Alloc2 __alloc2; |
| 4478 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4643 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4479 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); | 4644 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); |
| 4480 shared_ptr<_Tp> __r; | 4645 shared_ptr<_Tp> __r; |
| 4481 __r.__ptr_ = __hold2.get()->get(); | 4646 __r.__ptr_ = __hold2.get()->get(); |
| 4482 __r.__cntrl_ = __hold2.release(); | 4647 __r.__cntrl_ = __hold2.release(); |
| 4483 __r.__enable_weak_this(__r.__ptr_); | 4648 __r.__enable_weak_this(__r.__ptr_); |
| 4484 return __r; | 4649 return __r; |
| 4485 } | 4650 } |
| 4486 | 4651 |
| 4487 template<class _Tp> | 4652 template<class _Tp> |
| 4488 template<class _A0, class _A1> | 4653 template<class _A0, class _A1> |
| 4489 shared_ptr<_Tp> | 4654 shared_ptr<_Tp> |
| 4490 shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) | 4655 shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) |
| 4491 { | 4656 { |
| 4492 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 4657 typedef counting_allocator<_Tp, allocation_group::shared_ptr> _Alloc; |
| 4493 typedef allocator<_CntrlBlk> _Alloc2; | 4658 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4659 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4494 typedef __allocator_destructor<_Alloc2> _D2; | 4660 typedef __allocator_destructor<_Alloc2> _D2; |
| 4495 _Alloc2 __alloc2; | 4661 _Alloc2 __alloc2; |
| 4496 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4662 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4497 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); | 4663 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); |
| 4498 shared_ptr<_Tp> __r; | 4664 shared_ptr<_Tp> __r; |
| 4499 __r.__ptr_ = __hold2.get()->get(); | 4665 __r.__ptr_ = __hold2.get()->get(); |
| 4500 __r.__cntrl_ = __hold2.release(); | 4666 __r.__cntrl_ = __hold2.release(); |
| 4501 __r.__enable_weak_this(__r.__ptr_); | 4667 __r.__enable_weak_this(__r.__ptr_); |
| 4502 return __r; | 4668 return __r; |
| 4503 } | 4669 } |
| 4504 | 4670 |
| 4505 template<class _Tp> | 4671 template<class _Tp> |
| 4506 template<class _A0, class _A1, class _A2> | 4672 template<class _A0, class _A1, class _A2> |
| 4507 shared_ptr<_Tp> | 4673 shared_ptr<_Tp> |
| 4508 shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) | 4674 shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) |
| 4509 { | 4675 { |
| 4510 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 4676 typedef counting_allocator<_Tp, allocation_group::shared_ptr> _Alloc; |
| 4511 typedef allocator<_CntrlBlk> _Alloc2; | 4677 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4678 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4512 typedef __allocator_destructor<_Alloc2> _D2; | 4679 typedef __allocator_destructor<_Alloc2> _D2; |
| 4513 _Alloc2 __alloc2; | 4680 _Alloc2 __alloc2; |
| 4514 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4681 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4515 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); | 4682 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); |
| 4516 shared_ptr<_Tp> __r; | 4683 shared_ptr<_Tp> __r; |
| 4517 __r.__ptr_ = __hold2.get()->get(); | 4684 __r.__ptr_ = __hold2.get()->get(); |
| 4518 __r.__cntrl_ = __hold2.release(); | 4685 __r.__cntrl_ = __hold2.release(); |
| 4519 __r.__enable_weak_this(__r.__ptr_); | 4686 __r.__enable_weak_this(__r.__ptr_); |
| 4520 return __r; | 4687 return __r; |
| 4521 } | 4688 } |
| 4522 | 4689 |
| 4523 template<class _Tp> | 4690 template<class _Tp> |
| 4524 template<class _Alloc> | 4691 template<class _Alloc> |
| 4525 shared_ptr<_Tp> | 4692 shared_ptr<_Tp> |
| 4526 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a) | 4693 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a) |
| 4527 { | 4694 { |
| 4528 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 4695 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4529 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; | 4696 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4530 typedef __allocator_destructor<_Alloc2> _D2; | 4697 typedef __allocator_destructor<_Alloc2> _D2; |
| 4531 _Alloc2 __alloc2(__a); | 4698 _Alloc2 __alloc2(__a); |
| 4532 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4699 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4533 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | 4700 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) |
| 4534 _CntrlBlk(__a); | 4701 _CntrlBlk(__a); |
| 4535 shared_ptr<_Tp> __r; | 4702 shared_ptr<_Tp> __r; |
| 4536 __r.__ptr_ = __hold2.get()->get(); | 4703 __r.__ptr_ = __hold2.get()->get(); |
| 4537 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); | 4704 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); |
| 4538 __r.__enable_weak_this(__r.__ptr_); | 4705 __r.__enable_weak_this(__r.__ptr_); |
| 4539 return __r; | 4706 return __r; |
| 4540 } | 4707 } |
| 4541 | 4708 |
| 4542 template<class _Tp> | 4709 template<class _Tp> |
| 4543 template<class _Alloc, class _A0> | 4710 template<class _Alloc, class _A0> |
| 4544 shared_ptr<_Tp> | 4711 shared_ptr<_Tp> |
| 4545 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) | 4712 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) |
| 4546 { | 4713 { |
| 4547 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 4714 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4548 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; | 4715 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4549 typedef __allocator_destructor<_Alloc2> _D2; | 4716 typedef __allocator_destructor<_Alloc2> _D2; |
| 4550 _Alloc2 __alloc2(__a); | 4717 _Alloc2 __alloc2(__a); |
| 4551 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4718 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4552 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | 4719 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) |
| 4553 _CntrlBlk(__a, __a0); | 4720 _CntrlBlk(__a, __a0); |
| 4554 shared_ptr<_Tp> __r; | 4721 shared_ptr<_Tp> __r; |
| 4555 __r.__ptr_ = __hold2.get()->get(); | 4722 __r.__ptr_ = __hold2.get()->get(); |
| 4556 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); | 4723 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); |
| 4557 __r.__enable_weak_this(__r.__ptr_); | 4724 __r.__enable_weak_this(__r.__ptr_); |
| 4558 return __r; | 4725 return __r; |
| 4559 } | 4726 } |
| 4560 | 4727 |
| 4561 template<class _Tp> | 4728 template<class _Tp> |
| 4562 template<class _Alloc, class _A0, class _A1> | 4729 template<class _Alloc, class _A0, class _A1> |
| 4563 shared_ptr<_Tp> | 4730 shared_ptr<_Tp> |
| 4564 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) | 4731 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) |
| 4565 { | 4732 { |
| 4566 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 4733 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4567 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; | 4734 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4568 typedef __allocator_destructor<_Alloc2> _D2; | 4735 typedef __allocator_destructor<_Alloc2> _D2; |
| 4569 _Alloc2 __alloc2(__a); | 4736 _Alloc2 __alloc2(__a); |
| 4570 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4737 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4571 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | 4738 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) |
| 4572 _CntrlBlk(__a, __a0, __a1); | 4739 _CntrlBlk(__a, __a0, __a1); |
| 4573 shared_ptr<_Tp> __r; | 4740 shared_ptr<_Tp> __r; |
| 4574 __r.__ptr_ = __hold2.get()->get(); | 4741 __r.__ptr_ = __hold2.get()->get(); |
| 4575 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); | 4742 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); |
| 4576 __r.__enable_weak_this(__r.__ptr_); | 4743 __r.__enable_weak_this(__r.__ptr_); |
| 4577 return __r; | 4744 return __r; |
| 4578 } | 4745 } |
| 4579 | 4746 |
| 4580 template<class _Tp> | 4747 template<class _Tp> |
| 4581 template<class _Alloc, class _A0, class _A1, class _A2> | 4748 template<class _Alloc, class _A0, class _A1, class _A2> |
| 4582 shared_ptr<_Tp> | 4749 shared_ptr<_Tp> |
| 4583 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& _
_a2) | 4750 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& _
_a2) |
| 4584 { | 4751 { |
| 4585 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 4752 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; |
| 4586 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; | 4753 typedef typename __rebind_counting_alloc_helper<allocator_traits<_Alloc>, _C
ntrlBlk>::type _Alloc2; |
| 4587 typedef __allocator_destructor<_Alloc2> _D2; | 4754 typedef __allocator_destructor<_Alloc2> _D2; |
| 4588 _Alloc2 __alloc2(__a); | 4755 _Alloc2 __alloc2(__a); |
| 4589 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 4756 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); |
| 4590 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) | 4757 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) |
| 4591 _CntrlBlk(__a, __a0, __a1, __a2); | 4758 _CntrlBlk(__a, __a0, __a1, __a2); |
| 4592 shared_ptr<_Tp> __r; | 4759 shared_ptr<_Tp> __r; |
| 4593 __r.__ptr_ = __hold2.get()->get(); | 4760 __r.__ptr_ = __hold2.get()->get(); |
| 4594 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); | 4761 __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); |
| 4595 __r.__enable_weak_this(__r.__ptr_); | 4762 __r.__enable_weak_this(__r.__ptr_); |
| 4596 return __r; | 4763 return __r; |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5658 #if _LIBCPP_STD_VER > 14 | 5825 #if _LIBCPP_STD_VER > 14 |
| 5659 || _Traits::is_always_equal::value | 5826 || _Traits::is_always_equal::value |
| 5660 #else | 5827 #else |
| 5661 && is_nothrow_move_assignable<_Alloc>::value | 5828 && is_nothrow_move_assignable<_Alloc>::value |
| 5662 #endif | 5829 #endif |
| 5663 > {}; | 5830 > {}; |
| 5664 | 5831 |
| 5665 _LIBCPP_END_NAMESPACE_STD | 5832 _LIBCPP_END_NAMESPACE_STD |
| 5666 | 5833 |
| 5667 #endif // _LIBCPP_MEMORY | 5834 #endif // _LIBCPP_MEMORY |
| OLD | NEW |