diff options
| author | Eric Fiselier <eric@efcs.ca> | 2019-11-16 17:13:26 -0500 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2019-11-16 17:16:09 -0500 |
| commit | 0068c5913999b14627c27433c8d846a2ef5fbe00 (patch) | |
| tree | 1ca9de27cd7097660bd6083bbdc75a493819ab07 /libcxx | |
| parent | 2916489c54a303971bc546f287b71532d49ddd33 (diff) | |
| download | bcm5719-llvm-0068c5913999b14627c27433c8d846a2ef5fbe00.tar.gz bcm5719-llvm-0068c5913999b14627c27433c8d846a2ef5fbe00.zip | |
[libc++] Rename __to_raw_pointer to __to_address.
This function has the same behavior as the now-standand std::to_address.
Re-using the name makes the behavior more clear, and in the future it
will allow us to correctly get the raw pointer for user provided pointer
types.
Diffstat (limited to 'libcxx')
| -rw-r--r-- | libcxx/include/__bit_reference | 12 | ||||
| -rw-r--r-- | libcxx/include/__split_buffer | 24 | ||||
| -rw-r--r-- | libcxx/include/deque | 10 | ||||
| -rw-r--r-- | libcxx/include/memory | 65 | ||||
| -rw-r--r-- | libcxx/include/string | 80 | ||||
| -rw-r--r-- | libcxx/include/type_traits | 2 | ||||
| -rw-r--r-- | libcxx/include/vector | 18 |
7 files changed, 111 insertions, 100 deletions
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference index cce74fb5023..05dfbe7e9ff 100644 --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -332,7 +332,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type)); + _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -362,7 +362,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type)); + _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -429,8 +429,8 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon // __first.__ctz_ == 0; // do middle words __storage_type __nw = __n / __bits_per_word; - _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), - _VSTD::__to_raw_pointer(__first.__seg_), + _VSTD::memmove(_VSTD::__to_address(__result.__seg_), + _VSTD::__to_address(__first.__seg_), __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; __result.__seg_ += __nw; @@ -570,8 +570,8 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C __storage_type __nw = __n / __bits_per_word; __result.__seg_ -= __nw; __last.__seg_ -= __nw; - _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), - _VSTD::__to_raw_pointer(__last.__seg_), + _VSTD::memmove(_VSTD::__to_address(__result.__seg_), + _VSTD::__to_address(__last.__seg_), __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last word diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer index 095fe8928c6..f221aee074f 100644 --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -212,7 +212,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) { _ConstructTransaction __tx(&this->__end_, __n); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { - __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_)); + __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_)); } } @@ -229,7 +229,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen _ConstructTransaction __tx(&this->__end_, __n); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { __alloc_traits::construct(this->__alloc(), - _VSTD::__to_raw_pointer(__tx.__pos_), __x); + _VSTD::__to_address(__tx.__pos_), __x); } } @@ -253,10 +253,10 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt __split_buffer __buf(__new_cap, 0, __a); for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_) __alloc_traits::construct(__buf.__alloc(), - _VSTD::__to_raw_pointer(__buf.__end_), _VSTD::move(*__p)); + _VSTD::__to_address(__buf.__end_), _VSTD::move(*__p)); swap(__buf); } - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); + __alloc_traits::construct(__a, _VSTD::__to_address(this->__end_), *__first); ++this->__end_; } } @@ -273,7 +273,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F _ConstructTransaction __tx(&this->__end_, std::distance(__first, __last)); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, ++__first) { __alloc_traits::construct(this->__alloc(), - _VSTD::__to_raw_pointer(__tx.__pos_), *__first); + _VSTD::__to_address(__tx.__pos_), *__first); } } @@ -283,7 +283,7 @@ void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { while (__begin_ != __new_begin) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++)); + __alloc_traits::destroy(__alloc(), __to_address(__begin_++)); } template <class _Tp, class _Allocator> @@ -300,7 +300,7 @@ void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { while (__new_last != __end_) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_)); + __alloc_traits::destroy(__alloc(), __to_address(--__end_)); } template <class _Tp, class _Allocator> @@ -495,7 +495,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) _VSTD::swap(__end_cap(), __t.__end_cap()); } } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), __x); + __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1), __x); --__begin_; } @@ -526,7 +526,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) _VSTD::swap(__end_cap(), __t.__end_cap()); } } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), + __alloc_traits::construct(__alloc(), _VSTD::__to_address(__begin_-1), _VSTD::move(__x)); --__begin_; } @@ -559,7 +559,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) _VSTD::swap(__end_cap(), __t.__end_cap()); } } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), __x); + __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_), __x); ++__end_; } @@ -590,7 +590,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) _VSTD::swap(__end_cap(), __t.__end_cap()); } } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), + __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_), _VSTD::move(__x)); ++__end_; } @@ -621,7 +621,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) _VSTD::swap(__end_cap(), __t.__end_cap()); } } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), + __alloc_traits::construct(__alloc(), _VSTD::__to_address(__end_), _VSTD::forward<_Args>(__args)...); ++__end_; } diff --git a/libcxx/include/deque b/libcxx/include/deque index cb7e4e53271..831b8e4948f 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -2374,7 +2374,7 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l, for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) { _ConstructTransaction __tx(this, __br); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) { - __alloc_traits::construct(__a, std::__to_raw_pointer(__tx.__pos_), *__f); + __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), *__f); } } } @@ -2391,7 +2391,7 @@ deque<_Tp, _Allocator>::__append(size_type __n) for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) { _ConstructTransaction __tx(this, __br); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { - __alloc_traits::construct(__a, std::__to_raw_pointer(__tx.__pos_)); + __alloc_traits::construct(__a, std::__to_address(__tx.__pos_)); } } } @@ -2408,7 +2408,7 @@ deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v) for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) { _ConstructTransaction __tx(this, __br); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { - __alloc_traits::construct(__a, std::__to_raw_pointer(__tx.__pos_), __v); + __alloc_traits::construct(__a, std::__to_address(__tx.__pos_), __v); } } @@ -2706,7 +2706,7 @@ void deque<_Tp, _Allocator>::pop_front() { allocator_type& __a = __base::__alloc(); - __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() + + __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() + __base::__start_ / __base::__block_size) + __base::__start_ % __base::__block_size)); --__base::size(); @@ -2721,7 +2721,7 @@ deque<_Tp, _Allocator>::pop_back() _LIBCPP_ASSERT(!empty(), "deque::pop_back called for empty deque"); allocator_type& __a = __base::__alloc(); size_type __p = __base::size() + __base::__start_ - 1; - __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() + + __alloc_traits::destroy(__a, __to_address(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size)); --__base::size(); diff --git a/libcxx/include/memory b/libcxx/include/memory index 96bb8fb5ccb..1723b30d39d 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -1098,40 +1098,51 @@ struct __const_void_pointer<_Ptr, _Alloc, false> #endif }; + +template <bool _UsePointerTraits> struct __to_address_helper; + +template <> struct __to_address_helper<true> { + template <class _Pointer> + using __return_type = decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>())); + + template <class _Pointer> + _LIBCPP_CONSTEXPR + static __return_type<_Pointer> + __do_it(const _Pointer &__p) _NOEXCEPT { return pointer_traits<_Pointer>::to_address(__p); } +}; + +template <class _Pointer, bool _Dummy = true> +using __choose_to_address = __to_address_helper<_IsValidExpansion<__to_address_helper<_Dummy>::template __return_type, _Pointer>::value>; + + template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp* -__to_raw_pointer(_Tp* __p) _NOEXCEPT +__to_address(_Tp* __p) _NOEXCEPT { + static_assert(!is_function<_Tp>::value, "_Tp is a function type"); return __p; } -#if _LIBCPP_STD_VER <= 17 -template <class _Pointer> -inline _LIBCPP_INLINE_VISIBILITY -typename pointer_traits<_Pointer>::element_type* -__to_raw_pointer(_Pointer __p) _NOEXCEPT -{ - return _VSTD::__to_raw_pointer(__p.operator->()); -} -#else template <class _Pointer> -inline _LIBCPP_INLINE_VISIBILITY -auto -__to_raw_pointer(const _Pointer& __p) _NOEXCEPT --> decltype(pointer_traits<_Pointer>::to_address(__p)) -{ - return pointer_traits<_Pointer>::to_address(__p); +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename __choose_to_address<_Pointer>::template __return_type<_Pointer> +__to_address(const _Pointer& __p) _NOEXCEPT { + return __choose_to_address<_Pointer>::__do_it(__p); } -template <class _Pointer, class... _None> -inline _LIBCPP_INLINE_VISIBILITY -auto -__to_raw_pointer(const _Pointer& __p, _None...) _NOEXCEPT -{ - return _VSTD::__to_raw_pointer(__p.operator->()); -} +template <> struct __to_address_helper<false> { + template <class _Pointer> + using __return_type = typename pointer_traits<_Pointer>::element_type*; + + template <class _Pointer> + _LIBCPP_CONSTEXPR + static __return_type<_Pointer> + __do_it(const _Pointer &__p) _NOEXCEPT { return std::__to_address(__p.operator->()); } +}; + +#if _LIBCPP_STD_VER > 17 template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY constexpr _Tp* @@ -1146,7 +1157,7 @@ inline _LIBCPP_INLINE_VISIBILITY auto to_address(const _Pointer& __p) _NOEXCEPT { - return _VSTD::__to_raw_pointer(__p); + return _VSTD::__to_address(__p); } #endif @@ -1638,7 +1649,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits static_assert(__is_cpp17_move_insertable<allocator_type>::value, "The specified type does not meet the requirements of Cpp17MoveInsertible"); for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) - construct(__a, _VSTD::__to_raw_pointer(__begin2), + construct(__a, _VSTD::__to_address(__begin2), #ifdef _LIBCPP_NO_EXCEPTIONS _VSTD::move(*__begin1) #else @@ -1674,7 +1685,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) { for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) - construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1); + construct(__a, _VSTD::__to_address(__begin2), *__begin1); } template <class _SourceTp, class _DestTp, @@ -1710,7 +1721,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits "The specified type does not meet the requirements of Cpp17MoveInsertable"); while (__end1 != __begin1) { - construct(__a, _VSTD::__to_raw_pointer(__end2 - 1), + construct(__a, _VSTD::__to_address(__end2 - 1), #ifdef _LIBCPP_NO_EXCEPTIONS _VSTD::move(*--__end1) #else diff --git a/libcxx/include/string b/libcxx/include/string index 3368fb8bfcd..024467a7cd2 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1239,10 +1239,10 @@ public: _LIBCPP_INLINE_VISIBILITY const value_type* c_str() const _NOEXCEPT {return data();} _LIBCPP_INLINE_VISIBILITY - const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());} + const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(__get_pointer());} #if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_INLINE_VISIBILITY - value_type* data() _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());} + value_type* data() _NOEXCEPT {return _VSTD::__to_address(__get_pointer());} #endif _LIBCPP_INLINE_VISIBILITY @@ -1765,7 +1765,7 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, __set_long_cap(__cap+1); __set_long_size(__sz); } - traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); + traits_type::copy(_VSTD::__to_address(__p), __s, __sz); traits_type::assign(__p[__sz], value_type()); } @@ -1789,7 +1789,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty __set_long_cap(__cap+1); __set_long_size(__sz); } - traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); + traits_type::copy(_VSTD::__to_address(__p), __s, __sz); traits_type::assign(__p[__sz], value_type()); } @@ -1835,7 +1835,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; else - __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); + __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif @@ -1849,7 +1849,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; else - __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); + __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif @@ -1881,7 +1881,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co : __r_(__second_tag(), __a) { if (__str.__is_long() && __a != __str.__alloc()) // copy, not move - __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); + __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); else { __r_.first().__r = __str.__r_.first().__r; @@ -1916,7 +1916,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) __set_long_cap(__cap+1); __set_long_size(__n); } - traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c); + traits_type::assign(_VSTD::__to_address(__p), __n, __c); traits_type::assign(__p[__n], value_type()); } @@ -2144,14 +2144,14 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); __invalidate_all_iterators(); if (__n_copy != 0) - traits_type::copy(_VSTD::__to_raw_pointer(__p), - _VSTD::__to_raw_pointer(__old_p), __n_copy); + traits_type::copy(_VSTD::__to_address(__p), + _VSTD::__to_address(__old_p), __n_copy); if (__n_add != 0) - traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add); + traits_type::copy(_VSTD::__to_address(__p) + __n_copy, __p_new_stuff, __n_add); size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; if (__sec_cp_sz != 0) - traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, - _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz); + traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add, + _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); if (__old_cap+1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); __set_long_pointer(__p); @@ -2176,12 +2176,12 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); __invalidate_all_iterators(); if (__n_copy != 0) - traits_type::copy(_VSTD::__to_raw_pointer(__p), - _VSTD::__to_raw_pointer(__old_p), __n_copy); + traits_type::copy(_VSTD::__to_address(__p), + _VSTD::__to_address(__old_p), __n_copy); size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; if (__sec_cp_sz != 0) - traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, - _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, + traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add, + _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); if (__old_cap+1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); @@ -2199,7 +2199,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty size_type __cap = capacity(); if (__cap >= __n) { - value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); + value_type* __p = _VSTD::__to_address(__get_pointer()); traits_type::move(__p, __s, __n); traits_type::assign(__p[__n], value_type()); __set_size(__n); @@ -2225,7 +2225,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) } else __invalidate_iterators_past(__n); - value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); + value_type* __p = _VSTD::__to_address(__get_pointer()); traits_type::assign(__p, __n, __c); traits_type::assign(__p[__n], value_type()); __set_size(__n); @@ -2398,7 +2398,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty { if (__n) { - value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); + value_type* __p = _VSTD::__to_address(__get_pointer()); traits_type::copy(__p + __sz, __s, __n); __sz += __n; __set_size(__sz); @@ -2421,7 +2421,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) if (__cap - __sz < __n) __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); pointer __p = __get_pointer(); - traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c); + traits_type::assign(_VSTD::__to_address(__p) + __sz, __n, __c); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); @@ -2586,7 +2586,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t { if (__n) { - value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); + value_type* __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __pos; if (__n_move != 0) { @@ -2618,7 +2618,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n value_type* __p; if (__cap - __sz >= __n) { - __p = _VSTD::__to_raw_pointer(__get_pointer()); + __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __pos; if (__n_move != 0) traits_type::move(__p + __pos + __n, __p + __pos, __n_move); @@ -2626,7 +2626,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n else { __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); - __p = _VSTD::__to_raw_pointer(__get_long_pointer()); + __p = _VSTD::__to_address(__get_long_pointer()); } traits_type::assign(__p + __pos, __n, __c); __sz += __n; @@ -2687,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward value_type* __p; if (__cap - __sz >= __n) { - __p = _VSTD::__to_raw_pointer(__get_pointer()); + __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __ip; if (__n_move != 0) traits_type::move(__p + __ip + __n, __p + __ip, __n_move); @@ -2695,7 +2695,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward else { __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); - __p = _VSTD::__to_raw_pointer(__get_long_pointer()); + __p = _VSTD::__to_address(__get_long_pointer()); } __sz += __n; __set_size(__sz); @@ -2761,11 +2761,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty if (__cap == __sz) { __grow_by(__cap, 1, __sz, __ip, 0, 1); - __p = _VSTD::__to_raw_pointer(__get_long_pointer()); + __p = _VSTD::__to_address(__get_long_pointer()); } else { - __p = _VSTD::__to_raw_pointer(__get_pointer()); + __p = _VSTD::__to_address(__get_pointer()); size_type __n_move = __sz - __ip; if (__n_move != 0) traits_type::move(__p + __ip + 1, __p + __ip, __n_move); @@ -2806,7 +2806,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ size_type __cap = capacity(); if (__cap - __sz + __n1 >= __n2) { - value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); + value_type* __p = _VSTD::__to_address(__get_pointer()); if (__n1 != __n2) { size_type __n_move = __sz - __pos - __n1; @@ -2861,7 +2861,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ value_type* __p; if (__cap - __sz + __n1 >= __n2) { - __p = _VSTD::__to_raw_pointer(__get_pointer()); + __p = _VSTD::__to_address(__get_pointer()); if (__n1 != __n2) { size_type __n_move = __sz - __pos - __n1; @@ -2872,7 +2872,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ else { __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); - __p = _VSTD::__to_raw_pointer(__get_long_pointer()); + __p = _VSTD::__to_address(__get_long_pointer()); } traits_type::assign(__p + __pos, __n2, __c); __sz += __n2 - __n1; @@ -2984,7 +2984,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) this->__throw_out_of_range(); if (__n) { - value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); + value_type* __p = _VSTD::__to_address(__get_pointer()); __n = _VSTD::min(__n, __sz - __pos); size_type __n_move = __sz - __pos - __n; if (__n_move != 0) @@ -3172,8 +3172,8 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg) __was_long = __is_long(); __p = __get_pointer(); } - traits_type::copy(_VSTD::__to_raw_pointer(__new_data), - _VSTD::__to_raw_pointer(__p), size()+1); + traits_type::copy(_VSTD::__to_address(__new_data), + _VSTD::__to_address(__p), size()+1); if (__was_long) __alloc_traits::deallocate(__alloc(), __p, __cap+1); if (__now_long) @@ -4284,23 +4284,23 @@ template<class _CharT, class _Traits, class _Allocator> bool basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const { - return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && - _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size(); + return this->data() <= _VSTD::__to_address(__i->base()) && + _VSTD::__to_address(__i->base()) < this->data() + this->size(); } template<class _CharT, class _Traits, class _Allocator> bool basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const { - return this->data() < _VSTD::__to_raw_pointer(__i->base()) && - _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size(); + return this->data() < _VSTD::__to_address(__i->base()) && + _VSTD::__to_address(__i->base()) <= this->data() + this->size(); } template<class _CharT, class _Traits, class _Allocator> bool basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const { - const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + const value_type* __p = _VSTD::__to_address(__i->base()) + __n; return this->data() <= __p && __p <= this->data() + this->size(); } @@ -4308,7 +4308,7 @@ template<class _CharT, class _Traits, class _Allocator> bool basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const { - const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + const value_type* __p = _VSTD::__to_address(__i->base()) + __n; return this->data() <= __p && __p < this->data() + this->size(); } diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 54aa93fabff..cd0aff96680 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -427,7 +427,6 @@ template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair; template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper; template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; - template <class _Tp, _Tp __v> struct _LIBCPP_TEMPLATE_VIS integral_constant { @@ -570,6 +569,7 @@ using _IsNotSame = _BoolConstant< !_VSTD::is_same<_Tp, _Up>::value #endif >; + // addressof #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF diff --git a/libcxx/include/vector b/libcxx/include/vector index be4894a89e2..f2bbdf28814 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -423,7 +423,7 @@ __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { pointer __soon_to_be_end = __end_; while (__new_last != __soon_to_be_end) - __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end)); + __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end)); __end_ = __new_last; } @@ -692,10 +692,10 @@ public: _LIBCPP_INLINE_VISIBILITY value_type* data() _NOEXCEPT - {return _VSTD::__to_raw_pointer(this->__begin_);} + {return _VSTD::__to_address(this->__begin_);} _LIBCPP_INLINE_VISIBILITY const value_type* data() const _NOEXCEPT - {return _VSTD::__to_raw_pointer(this->__begin_);} + {return _VSTD::__to_address(this->__begin_);} #ifdef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY @@ -921,7 +921,7 @@ private: _LIBCPP_INLINE_VISIBILITY void __construct_one_at_end(_Args&& ...__args) { _ConstructTransaction __tx(*this, 1); - __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_), + __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), _VSTD::forward<_Args>(__args)...); ++__tx.__pos_; } @@ -1042,7 +1042,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) { _ConstructTransaction __tx(*this, __n); for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) { - __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_)); + __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_)); } } @@ -1059,7 +1059,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { _ConstructTransaction __tx(*this, __n); for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) { - __alloc_traits::construct(this->__alloc(), _VSTD::__to_raw_pointer(__tx.__pos_), __x); + __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), __x); } } @@ -1622,7 +1622,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) allocator_type& __a = this->__alloc(); __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); // __v.push_back(_VSTD::forward<_Up>(__x)); - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Up>(__x)); + __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Up>(__x)); __v.__end_++; __swap_out_circular_buffer(__v); } @@ -1663,7 +1663,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) allocator_type& __a = this->__alloc(); __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); // __v.emplace_back(_VSTD::forward<_Args>(__args)...); - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Args>(__args)...); + __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Args>(__args)...); __v.__end_++; __swap_out_circular_buffer(__v); } @@ -1753,7 +1753,7 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe _ConstructTransaction __tx(*this, __from_e - __i); for (; __i < __from_e; ++__i, ++__tx.__pos_) { __alloc_traits::construct(this->__alloc(), - _VSTD::__to_raw_pointer(__tx.__pos_), + _VSTD::__to_address(__tx.__pos_), _VSTD::move(*__i)); } } |

