diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -1571,7 +1571,7 @@ { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); @@ -2599,7 +2599,7 @@ { (*__dp)->__c_ = nullptr; if (--__c->end_ != __dp) - memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*)); + _VSTD::memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*)); } } __get_db()->unlock(); diff --git a/libcxx/include/__locale b/libcxx/include/__locale --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -79,7 +79,7 @@ // locale name, otherwise it will be a semicolon-separated string listing // each category. In the second case, we know at least one category won't // be what we want, so we only have to check the first case. - if (strcmp(__l.__get_locale(), __lc) != 0) { + if (_VSTD::strcmp(__l.__get_locale(), __lc) != 0) { __locale_all = _strdup(__lc); if (__locale_all == nullptr) __throw_bad_alloc(); diff --git a/libcxx/include/__string b/libcxx/include/__string --- a/libcxx/include/__string +++ b/libcxx/include/__string @@ -55,7 +55,9 @@ #include <__config> #include // for search and min -#include // For EOF. +#include // for EOF +#include // for memcpy +#include // for wmemcpy #include // for __murmur2_or_cityhash #include <__debug> @@ -374,23 +376,23 @@ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n); + ? _VSTD::__move_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); } static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() - ? __copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); + ? _VSTD::__copy_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); } static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n); + ? _VSTD::__assign_constexpr(__s, __n, __a) + : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n); } static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -414,7 +416,7 @@ #if __has_feature(cxx_constexpr_string_builtins) return __builtin_memcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 - return memcmp(__s1, __s2, __n); + return _VSTD::memcmp(__s1, __s2, __n); #else for (; __n; --__n, ++__s1, ++__s2) { @@ -436,7 +438,7 @@ #if __has_feature(cxx_constexpr_string_builtins) return __builtin_char_memchr(__s, to_int_type(__a), __n); #elif _LIBCPP_STD_VER <= 14 - return (const char_type*) memchr(__s, to_int_type(__a), __n); + return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n); #else for (; __n; --__n) { @@ -477,23 +479,23 @@ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : wmemmove(__s1, __s2, __n); + ? _VSTD::__move_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n); } static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() - ? __copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : wmemcpy(__s1, __s2, __n); + ? _VSTD::__copy_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n); } static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : wmemset(__s, __a, __n); + ? _VSTD::__assign_constexpr(__s, __n, __a) + : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n); } static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} @@ -516,7 +518,7 @@ #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemcmp(__s1, __s2, __n); #elif _LIBCPP_STD_VER <= 14 - return wmemcmp(__s1, __s2, __n); + return _VSTD::wmemcmp(__s1, __s2, __n); #else for (; __n; --__n, ++__s1, ++__s2) { @@ -548,7 +550,7 @@ #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wcslen(__s); #elif _LIBCPP_STD_VER <= 14 - return wcslen(__s); + return _VSTD::wcslen(__s); #else size_t __len = 0; for (; !eq(*__s, char_type(0)); ++__s) @@ -566,7 +568,7 @@ #if __has_feature(cxx_constexpr_string_builtins) return __builtin_wmemchr(__s, __a, __n); #elif _LIBCPP_STD_VER <= 14 - return wmemchr(__s, __a, __n); + return _VSTD::wmemchr(__s, __a, __n); #else for (; __n; --__n) { @@ -610,8 +612,8 @@ char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, __n); + ? _VSTD::__move_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); } static _LIBCPP_CONSTEXPR_AFTER_CXX17 @@ -619,16 +621,16 @@ { _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() - ? __copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); + ? _VSTD::__copy_constexpr(__s1, __s2, __n) + : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); } static _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { return __libcpp_is_constant_evaluated() - ? __assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n); + ? _VSTD::__assign_constexpr(__s, __n, __a) + : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n); } static inline constexpr int_type not_eof(int_type __c) noexcept diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -1707,7 +1707,7 @@ _OutputIterator __copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - return __copy_constexpr(__first, __last, __result); + return _VSTD::__copy_constexpr(__first, __last, __result); } template @@ -1733,10 +1733,10 @@ { if (__libcpp_is_constant_evaluated()) { return _VSTD::__copy_constexpr( - __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); + _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result)); } else { return _VSTD::__copy( - __unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); + _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result)); } } @@ -1757,7 +1757,7 @@ _OutputIterator __copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) { - return __copy_backward_constexpr(__first, __last, __result); + return _VSTD::__copy_backward_constexpr(__first, __last, __result); } template @@ -1786,13 +1786,13 @@ _BidirectionalIterator2 __result) { if (__libcpp_is_constant_evaluated()) { - return _VSTD::__copy_backward_constexpr(__unwrap_iter(__first), - __unwrap_iter(__last), - __unwrap_iter(__result)); + return _VSTD::__copy_backward_constexpr(_VSTD::__unwrap_iter(__first), + _VSTD::__unwrap_iter(__last), + _VSTD::__unwrap_iter(__result)); } else { - return _VSTD::__copy_backward(__unwrap_iter(__first), - __unwrap_iter(__last), - __unwrap_iter(__result)); + return _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first), + _VSTD::__unwrap_iter(__last), + _VSTD::__unwrap_iter(__result)); } } @@ -1876,7 +1876,7 @@ _OutputIterator __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - return __move_constexpr(__first, __last, __result); + return _VSTD::__move_constexpr(__first, __last, __result); } template @@ -1890,7 +1890,7 @@ __move(_Tp* __first, _Tp* __last, _Up* __result) { if (__libcpp_is_constant_evaluated()) - return __move_constexpr(__first, __last, __result); + return _VSTD::__move_constexpr(__first, __last, __result); const size_t __n = static_cast(__last - __first); if (__n > 0) _VSTD::memmove(__result, __first, __n * sizeof(_Up)); @@ -1902,7 +1902,7 @@ _OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - return _VSTD::__move(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); + return _VSTD::__move(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result)); } // move_backward @@ -1924,7 +1924,7 @@ _OutputIterator __move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - return __move_backward_constexpr(__first, __last, __result); + return _VSTD::__move_backward_constexpr(__first, __last, __result); } template @@ -1938,7 +1938,7 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result) { if (__libcpp_is_constant_evaluated()) - return __move_backward_constexpr(__first, __last, __result); + return _VSTD::__move_backward_constexpr(__first, __last, __result); const size_t __n = static_cast(__last - __first); if (__n > 0) { @@ -1954,7 +1954,7 @@ move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) { - return _VSTD::__move_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); + return _VSTD::__move_backward(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result)); } // iter_swap @@ -3439,7 +3439,7 @@ // F????????????????? // f m l typedef typename add_lvalue_reference<_Predicate>::type _PredRef; - _ForwardIterator __first_false = __stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit); + _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit); // TTTFFFFF?????????? // f ff m l // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true @@ -3454,7 +3454,7 @@ } // TTTFFFFFTTTF?????? // f ff m m1 l - __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit); + __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit); __second_half_done: // TTTFFFFFTTTTTFFFFF // f ff m sf l @@ -3496,7 +3496,7 @@ __p = _VSTD::get_temporary_buffer(__len); __h.reset(__p.first); } - return __stable_partition::type> + return _VSTD::__stable_partition::type> (__first, __last, __pred, __len, __p, forward_iterator_tag()); } @@ -3582,7 +3582,7 @@ // F???TFFF?????????T // f m1 m l typedef typename add_lvalue_reference<_Predicate>::type _PredRef; - __first_false = __stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit); + __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit); __first_half_done: // TTTFFFFF?????????T // f ff m l @@ -3599,7 +3599,7 @@ } // TTTFFFFFTTTF?????T // f ff m m1 l - __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit); + __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit); __second_half_done: // TTTFFFFFTTTTTFFFFF // f ff m sf l @@ -3644,7 +3644,7 @@ __p = _VSTD::get_temporary_buffer(__len); __h.reset(__p.first); } - return __stable_partition::type> + return _VSTD::__stable_partition::type> (__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); } @@ -3653,7 +3653,7 @@ _ForwardIterator stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { - return __stable_partition::type> + return _VSTD::__stable_partition::type> (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); } @@ -3751,7 +3751,7 @@ __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _Compare __c) { - unsigned __r = __sort3<_Compare>(__x1, __x2, __x3, __c); + unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c); if (__c(*__x4, *__x3)) { swap(*__x3, *__x4); @@ -3778,7 +3778,7 @@ __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c) { - unsigned __r = __sort4<_Compare>(__x1, __x2, __x3, __x4, __c); + unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c); if (__c(*__x5, *__x4)) { swap(*__x4, *__x5); @@ -3843,7 +3843,7 @@ { typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; _RandomAccessIterator __j = __first+2; - __sort3<_Compare>(__first, __first+1, __j, __comp); + _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) { if (__comp(*__i, *__j)) @@ -3887,7 +3887,7 @@ } typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; _RandomAccessIterator __j = __first+2; - __sort3<_Compare>(__first, __first+1, __j, __comp); + _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); const unsigned __limit = 8; unsigned __count = 0; for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) @@ -4247,7 +4247,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp); + return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp); } template @@ -4291,7 +4291,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp); + return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp); } template @@ -4332,8 +4332,8 @@ _ForwardIterator __mp1 = __m; return pair<_ForwardIterator, _ForwardIterator> ( - __lower_bound<_Compare>(__first, __m, __value_, __comp), - __upper_bound<_Compare>(++__mp1, __last, __value_, __comp) + _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp), + _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp) ); } } @@ -4347,7 +4347,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __equal_range<_Comp_ref>(__first, __last, __value_, __comp); + return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp); } template @@ -4367,7 +4367,7 @@ bool __binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { - __first = __lower_bound<_Compare>(__first, __last, __value_, __comp); + __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp); return __first != __last && !__comp(__value_, *__first); } @@ -4378,7 +4378,7 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __binary_search<_Comp_ref>(__first, __last, __value_, __comp); + return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp); } template @@ -4483,7 +4483,7 @@ value_type* __p = __buff; for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr(), (void) ++__i, (void) ++__p) ::new(__p) value_type(_VSTD::move(*__i)); - __half_inplace_merge(__buff, __p, __middle, __last, __first, __comp); + _VSTD::__half_inplace_merge(__buff, __p, __middle, __last, __first, __comp); } else { @@ -4492,9 +4492,9 @@ ::new(__p) value_type(_VSTD::move(*__i)); typedef reverse_iterator<_BidirectionalIterator> _RBi; typedef reverse_iterator _Rv; - __half_inplace_merge(_Rv(__p), _Rv(__buff), - _RBi(__middle), _RBi(__first), - _RBi(__last), __invert<_Compare>(__comp)); + _VSTD::__half_inplace_merge(_Rv(__p), _Rv(__buff), + _RBi(__middle), _RBi(__first), + _RBi(__last), _VSTD::__invert<_Compare>(__comp)); } } @@ -4512,7 +4512,7 @@ if (__len2 == 0) return; if (__len1 <= __buff_size || __len2 <= __buff_size) - return __buffered_inplace_merge<_Compare> + return _VSTD::__buffered_inplace_merge<_Compare> (__first, __middle, __last, __comp, __len1, __len2, __buff); // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0 for (; true; ++__first, (void) --__len1) @@ -4540,7 +4540,7 @@ __len21 = __len2 / 2; __m2 = __middle; _VSTD::advance(__m2, __len21); - __m1 = __upper_bound<_Compare>(__first, __middle, *__m2, __comp); + __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp); __len11 = _VSTD::distance(__first, __m1); } else @@ -4555,7 +4555,7 @@ __len11 = __len1 / 2; __m1 = __first; _VSTD::advance(__m1, __len11); - __m2 = __lower_bound<_Compare>(__middle, __last, *__m1, __comp); + __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp); __len21 = _VSTD::distance(__middle, __m2); } difference_type __len12 = __len1 - __len11; // distance(__m1, __middle) @@ -4567,8 +4567,8 @@ // merge smaller range with recurisve call and larger with tail recursion elimination if (__len11 + __len21 < __len12 + __len22) { - __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); -// __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); + _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); +// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); __first = __middle; __middle = __m2; __len1 = __len12; @@ -4576,8 +4576,8 @@ } else { - __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); -// __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); + _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); +// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); __last = __middle; __middle = __m1; __len1 = __len11; @@ -4726,14 +4726,14 @@ } if (__len <= 8) { - __insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp); + _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp); return; } typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; _RandomAccessIterator __m = __first1 + __l2; - __stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2); - __stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2); - __merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp); + _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2); + _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2); + _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp); } template @@ -4762,7 +4762,7 @@ } if (__len <= static_cast(__stable_sort_switch::value)) { - __insertion_sort<_Compare>(__first, __last, __comp); + _VSTD::__insertion_sort<_Compare>(__first, __last, __comp); return; } typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; @@ -4771,21 +4771,21 @@ { __destruct_n __d(0); unique_ptr __h2(__buff, __d); - __stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff); + _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff); __d.__set(__l2, (value_type*)nullptr); - __stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2); + _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2); __d.__set(__len, (value_type*)nullptr); - __merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp); -// __merge<_Compare>(move_iterator(__buff), -// move_iterator(__buff + __l2), -// move_iterator<_RandomAccessIterator>(__buff + __l2), -// move_iterator<_RandomAccessIterator>(__buff + __len), -// __first, __comp); + _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp); +// _VSTD::__merge<_Compare>(move_iterator(__buff), +// move_iterator(__buff + __l2), +// move_iterator<_RandomAccessIterator>(__buff + __l2), +// move_iterator<_RandomAccessIterator>(__buff + __len), +// __first, __comp); return; } - __stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size); - __stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size); - __inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size); + _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size); + _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size); + _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size); } template @@ -4804,7 +4804,7 @@ __h.reset(__buf.first); } typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); + _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); } template @@ -4908,7 +4908,7 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - __sift_up<_Comp_ref>(__first, __last, __comp, __last - __first); + _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first); } template @@ -4985,7 +4985,7 @@ if (__len > 1) { swap(*__first, *--__last); - __sift_down<_Compare>(__first, __last, __comp, __len - 1, __first); + _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first); } } @@ -4995,7 +4995,7 @@ pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); + _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); } template @@ -5019,7 +5019,7 @@ // start from the first parent, there is no need to consider children for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) { - __sift_down<_Compare>(__first, __last, __comp, __n, __first + __start); + _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start); } } } @@ -5030,7 +5030,7 @@ make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - __make_heap<_Comp_ref>(__first, __last, __comp); + _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp); } template @@ -5049,7 +5049,7 @@ { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n) - __pop_heap<_Compare>(__first, __last, __comp, __n); + _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n); } template @@ -5058,7 +5058,7 @@ sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - __sort_heap<_Comp_ref>(__first, __last, __comp); + _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp); } template @@ -5076,17 +5076,17 @@ __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { - __make_heap<_Compare>(__first, __middle, __comp); + _VSTD::__make_heap<_Compare>(__first, __middle, __comp); typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first; for (_RandomAccessIterator __i = __middle; __i != __last; ++__i) { if (__comp(*__i, *__first)) { swap(*__i, *__first); - __sift_down<_Compare>(__first, __middle, __comp, __len, __first); + _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first); } } - __sort_heap<_Compare>(__first, __middle, __comp); + _VSTD::__sort_heap<_Compare>(__first, __middle, __comp); } template @@ -5096,7 +5096,7 @@ _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - __partial_sort<_Comp_ref>(__first, __middle, __last, __comp); + _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp); } template @@ -5120,15 +5120,15 @@ { for (; __first != __last && __r != __result_last; ++__first, (void) ++__r) *__r = *__first; - __make_heap<_Compare>(__result_first, __r, __comp); + _VSTD::__make_heap<_Compare>(__result_first, __r, __comp); typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first; for (; __first != __last; ++__first) if (__comp(*__first, *__result_first)) { *__result_first = *__first; - __sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first); + _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first); } - __sort_heap<_Compare>(__result_first, __r, __comp); + _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp); } return __r; } @@ -5140,7 +5140,7 @@ _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); + return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); } template @@ -5186,7 +5186,7 @@ } if (__len <= __limit) { - __selection_sort<_Compare>(__first, __last, __comp); + _VSTD::__selection_sort<_Compare>(__first, __last, __comp); return; } // __len > __limit >= 3 @@ -5210,7 +5210,7 @@ if (__i == --__j) { // *__first == *__m, *__m <= all other elements - // Parition instead into [__first, __i) == *__first and *__first < [__i, __last) + // Partition instead into [__first, __i) == *__first and *__first < [__i, __last) ++__i; // __first + 1 __j = __last; if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1) @@ -5248,8 +5248,8 @@ // The first part is sorted, if (__nth < __i) return; - // __nth_element the secod part - // __nth_element<_Compare>(__i, __nth, __last, __comp); + // __nth_element the second part + // _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp); __first = __i; goto __restart; } @@ -5331,12 +5331,12 @@ // __nth_element on range containing __nth if (__nth < __i) { - // __nth_element<_Compare>(__first, __nth, __i, __comp); + // _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp); __last = __i; } else { - // __nth_element<_Compare>(__i+1, __nth, __last, __comp); + // _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp); __first = ++__i; } } @@ -5348,7 +5348,7 @@ nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - __nth_element<_Comp_ref>(__first, __nth, __last, __comp); + _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp); } template @@ -5384,7 +5384,7 @@ _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); + return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); } template @@ -5432,7 +5432,7 @@ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); + return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); } template @@ -5478,7 +5478,7 @@ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); + return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); } template @@ -5526,7 +5526,7 @@ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); + return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); } template @@ -5579,7 +5579,7 @@ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); + return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); } template @@ -5618,7 +5618,7 @@ _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); + return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); } template @@ -5668,7 +5668,7 @@ next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __next_permutation<_Comp_ref>(__first, __last, __comp); + return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp); } template @@ -5715,7 +5715,7 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return __prev_permutation<_Comp_ref>(__first, __last, __comp); + return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp); } template diff --git a/libcxx/include/atomic b/libcxx/include/atomic --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -662,7 +662,7 @@ template _LIBCPP_INLINE_VISIBILITY bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) { - return memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0; + return _VSTD::memcmp(&__lhs, &__rhs, sizeof(_Tp)) == 0; } static_assert((is_same::type, __memory_order_underlying_t>::value), @@ -1262,7 +1262,7 @@ _Tp __temp; __a->__lock(); __cxx_atomic_assign_volatile(__temp, __a->__a_value); - bool __ret = (memcmp(&__temp, __expected, sizeof(_Tp)) == 0); + bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0); if(__ret) __cxx_atomic_assign_volatile(__a->__a_value, __value); else @@ -1275,11 +1275,11 @@ bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) { __a->__lock(); - bool __ret = (memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0); + bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0); if(__ret) - memcpy(&__a->__a_value, &__value, sizeof(_Tp)); + _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp)); else - memcpy(__expected, &__a->__a_value, sizeof(_Tp)); + _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp)); __a->__unlock(); return __ret; } @@ -1291,7 +1291,7 @@ _Tp __temp; __a->__lock(); __cxx_atomic_assign_volatile(__temp, __a->__a_value); - bool __ret = (memcmp(&__temp, __expected, sizeof(_Tp)) == 0); + bool __ret = (_VSTD::memcmp(&__temp, __expected, sizeof(_Tp)) == 0); if(__ret) __cxx_atomic_assign_volatile(__a->__a_value, __value); else @@ -1304,11 +1304,11 @@ bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) { __a->__lock(); - bool __ret = (memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0); + bool __ret = (_VSTD::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0); if(__ret) - memcpy(&__a->__a_value, &__value, sizeof(_Tp)); + _VSTD::memcpy(&__a->__a_value, &__value, sizeof(_Tp)); else - memcpy(__expected, &__a->__a_value, sizeof(_Tp)); + _VSTD::memcpy(__expected, &__a->__a_value, sizeof(_Tp)); __a->__unlock(); return __ret; } diff --git a/libcxx/include/charconv b/libcxx/include/charconv --- a/libcxx/include/charconv +++ b/libcxx/include/charconv @@ -76,11 +76,11 @@ #include <__config> #include <__availability> #include <__errc> -#include +#include +#include +#include #include -#include -#include -#include +#include #include <__debug> @@ -333,7 +333,7 @@ auto __len = __p - __buf; if (__len <= __diff) { - memcpy(__first, __buf, __len); + _VSTD::memcpy(__first, __buf, __len); return {__first + __len, {}}; } else @@ -382,7 +382,7 @@ return {__last, errc::value_too_large}; else { - memmove(__first, __p, __len); + _VSTD::memmove(__first, __p, __len); return {__first + __len, {}}; } } @@ -429,7 +429,7 @@ if (__x <= __complement(__to_unsigned(__tl::min()))) { __x = __complement(__x); - memcpy(&__value, &__x, sizeof(__x)); + _VSTD::memcpy(&__value, &__x, sizeof(__x)); return __r; } } diff --git a/libcxx/include/fstream b/libcxx/include/fstream --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -721,7 +721,7 @@ int_type __c = traits_type::eof(); if (this->gptr() == this->egptr()) { - memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); + _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); if (__always_noconv_) { size_t __nmemb = static_cast(this->egptr() - this->eback() - __unget_sz); @@ -738,7 +738,7 @@ { _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" ); if (__extbufend_ != __extbufnext_) - memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); + _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); size_t __nmemb = _VSTD::min(static_cast(__ibs_ - __unget_sz), diff --git a/libcxx/include/iterator b/libcxx/include/iterator --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -665,7 +665,7 @@ "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize; _IntegralSize __n = __orig_n; - __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); + _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); } template @@ -692,7 +692,7 @@ typename iterator_traits<_InputIter>::difference_type distance(_InputIter __first, _InputIter __last) { - return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); + return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); } template diff --git a/libcxx/include/list b/libcxx/include/list --- a/libcxx/include/list +++ b/libcxx/include/list @@ -810,7 +810,7 @@ { __cn2->__add(*__p); if (--__cn1->end_ != __p) - memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*)); } else (*__p)->__c_ = __cn1; @@ -823,7 +823,7 @@ { __cn1->__add(*__p); if (--__cn2->end_ != __p) - memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*)); } else (*__p)->__c_ = __cn2; @@ -1758,7 +1758,7 @@ { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); @@ -1787,7 +1787,7 @@ { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); @@ -1823,7 +1823,7 @@ { (*__ip)->__c_ = nullptr; if (--__c->end_ != __ip) - memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*)); + _VSTD::memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*)); } } __get_db()->unlock(); @@ -1869,7 +1869,7 @@ { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); @@ -2034,7 +2034,7 @@ __cn1->__add(*__ip); (*__ip)->__c_ = __cn1; if (--__cn2->end_ != __ip) - memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*)); + _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*)); } } __db->unlock(); @@ -2079,7 +2079,7 @@ __cn1->__add(*__ip); (*__ip)->__c_ = __cn1; if (--__cn2->end_ != __ip) - memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*)); + _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*)); } } __db->unlock(); @@ -2138,7 +2138,7 @@ __cn1->__add(*__ip); (*__ip)->__c_ = __cn1; if (--__cn2->end_ != __ip) - memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*)); + _VSTD::memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*)); } } } @@ -2271,7 +2271,7 @@ __cn1->__add(*__p); (*__p)->__c_ = __cn1; if (--__cn2->end_ != __p) - memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*)); } } __db->unlock(); diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -873,8 +873,8 @@ const numpunct<_CharT>& __np = use_facet >(__iob.getloc()); typedef typename numpunct<_CharT>::string_type string_type; const string_type __names[2] = {__np.truename(), __np.falsename()}; - const string_type* __i = __scan_keyword(__b, __e, __names, __names+2, - __ct, __err); + const string_type* __i = _VSTD::__scan_keyword(__b, __e, __names, __names+2, + __ct, __err); __v = __i == __names; return __b; } @@ -1912,7 +1912,7 @@ { // Note: ignoring case comes from the POSIX strptime spec const string_type* __wk = this->__weeks(); - ptrdiff_t __i = __scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk; + ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk; if (__i < 14) __w = __i % 7; } @@ -1926,7 +1926,7 @@ { // Note: ignoring case comes from the POSIX strptime spec const string_type* __month = this->__months(); - ptrdiff_t __i = __scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month; + ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month; if (__i < 24) __m = __i % 12; } @@ -1938,7 +1938,7 @@ ios_base::iostate& __err, const ctype& __ct) const { - int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2); + int __t = _VSTD::__get_up_to_n_digits(__b, __e, __err, __ct, 2); if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31) __d = __t; else @@ -2098,7 +2098,7 @@ __err |= ios_base::failbit; return; } - ptrdiff_t __i = __scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap; + ptrdiff_t __i = _VSTD::__scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap; if (__i == 0 && __h == 12) __h = 0; else if (__i == 1 && __h < 12) @@ -3578,7 +3578,7 @@ char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str()); string_type __w; __widen_from_utf8()(back_inserter(__w), - __n, __n + strlen(__n)); + __n, __n + _VSTD::strlen(__n)); return __w; #else // !_LIBCPP_HAS_CATOPEN _LIBCPP_UNUSED_VAR(__c); @@ -3999,7 +3999,7 @@ int_type __c = traits_type::eof(); if (this->gptr() == this->egptr()) { - memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); + _VSTD::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); if (__always_noconv_) { streamsize __nmemb = static_cast(this->egptr() - this->eback() - __unget_sz); @@ -4016,7 +4016,7 @@ { _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" ); if (__extbufend_ != __extbufnext_) - memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); + _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); streamsize __nmemb = _VSTD::min(static_cast(this->egptr() - this->eback() - __unget_sz), diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1774,7 +1774,7 @@ { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); diff --git a/libcxx/include/strstream b/libcxx/include/strstream --- a/libcxx/include/strstream +++ b/libcxx/include/strstream @@ -290,7 +290,7 @@ _LIBCPP_INLINE_VISIBILITY ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) : ostream(&__sb_), - __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0)) + __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0)) {} #ifndef _LIBCPP_CXX03_LANG @@ -350,7 +350,7 @@ _LIBCPP_INLINE_VISIBILITY strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) : iostream(&__sb_), - __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0)) + __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0)) {} #ifndef _LIBCPP_CXX03_LANG diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -2139,7 +2139,7 @@ if (__i->base() > __new_last) { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); diff --git a/libcxx/test/std/algorithms/robust_against_adl.pass.cpp b/libcxx/test/std/algorithms/robust_against_adl.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/algorithms/robust_against_adl.pass.cpp @@ -0,0 +1,96 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03 + +// + +#include +#include + +#include "test_macros.h" + +struct Incomplete; +template struct Holder { T t; }; + +struct Tester { + using Element = Holder*; + Element data[10]; +}; + +TEST_CONSTEXPR_CXX20 bool test() +{ + Tester t {}; + Tester u {}; + + // THESE RELY ON ADL SWAP IN PRACTICE: + // swap_ranges, iter_swap, reverse, rotate, partition + // sort, nth_element + // pop_heap, sort_heap, partial_sort, partial_sort_copy + // next_permutation, prev_permutation + // stable_partition, stable_sort, inplace_merge + // THESE RELY ON ADL SWAP IN THEORY: + // push_heap, make_heap + + std::copy(t.data, t.data+10, u.data); + std::copy_backward(t.data, t.data+10, u.data+10); + std::distance(t.data, t.data+10); + std::fill(t.data, t.data+10, nullptr); + std::for_each(t.data, t.data+10, [](void*){}); + std::generate(t.data, t.data+10, [](){ return nullptr; }); + std::move(t.data, t.data+10, u.data); + std::move_backward(t.data, t.data+10, u.data+10); + std::remove(t.data, t.data+10, nullptr); + std::remove_copy(t.data, t.data+10, u.data, nullptr); + std::remove_if(t.data, t.data+10, [](void*){ return true; }); + std::remove_copy_if(t.data, t.data+10, u.data, [](void*){ return true; }); + std::transform(t.data, t.data+10, u.data, [](void*){ return nullptr; }); + + // WITHOUT COMPARATORS + std::unique(t.data, t.data+10); + std::unique_copy(t.data, t.data+10, u.data); + std::binary_search(t.data, t.data+10, t.data[5]); + std::lower_bound(t.data, t.data+10, t.data[5]); + std::upper_bound(t.data, t.data+10, t.data[5]); + std::equal_range(t.data, t.data+10, t.data[5]); + std::equal(t.data, t.data+10, u.data, u.data+10); + std::lexicographical_compare(t.data, t.data+10, u.data, u.data+10); + std::set_union(t.data, t.data+5, t.data+5, t.data+10, u.data); + std::set_intersection(t.data, t.data+5, t.data+5, t.data+10, u.data); + std::set_difference(t.data, t.data+5, t.data+5, t.data+10, u.data); + std::set_symmetric_difference(t.data, t.data+5, t.data+5, t.data+10, u.data); + std::merge(t.data, t.data+5, t.data+5, t.data+10, u.data); + std::includes(t.data, t.data+10, u.data, u.data+10); + + // WITH COMPARATORS + std::unique(t.data, t.data+10, std::equal_to()); + std::unique_copy(t.data, t.data+10, u.data, std::equal_to()); + std::binary_search(t.data, t.data+10, nullptr, std::less()); + std::lower_bound(t.data, t.data+10, nullptr, std::less()); + std::upper_bound(t.data, t.data+10, nullptr, std::less()); + std::equal_range(t.data, t.data+10, nullptr, std::less()); + std::equal(t.data, t.data+10, u.data, u.data+10, std::equal_to()); + std::lexicographical_compare(t.data, t.data+10, u.data, u.data+10, std::less()); + std::set_union(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less()); + std::set_intersection(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less()); + std::set_difference(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less()); + std::set_symmetric_difference(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less()); + std::merge(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less()); + std::includes(t.data, t.data+10, u.data, u.data+10, std::less()); + + return true; +} + +int main(int, char**) +{ + test(); +#if TEST_STD_VER >= 20 + static_assert(test()); +#endif + return 0; +}