54 changes: 27 additions & 27 deletions libcxx/include/__functional_base
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
template <class _Tp, class ..._Args>
struct __invoke_return
{
typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
};

#else // defined(_LIBCPP_CXX03_LANG)
Expand All @@ -314,27 +314,27 @@ struct __invoke_void_return_wrapper
#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
static _Ret __call(_Args&&... __args) {
return __invoke(_VSTD::forward<_Args>(__args)...);
return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
}
#else
template <class _Fn>
static _Ret __call(_Fn __f) {
return __invoke(__f);
return _VSTD::__invoke(__f);
}

template <class _Fn, class _A0>
static _Ret __call(_Fn __f, _A0& __a0) {
return __invoke(__f, __a0);
return _VSTD::__invoke(__f, __a0);
}

template <class _Fn, class _A0, class _A1>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
return __invoke(__f, __a0, __a1);
return _VSTD::__invoke(__f, __a0, __a1);
}

template <class _Fn, class _A0, class _A1, class _A2>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
return __invoke(__f, __a0, __a1, __a2);
return _VSTD::__invoke(__f, __a0, __a1, __a2);
}
#endif
};
Expand All @@ -345,27 +345,27 @@ struct __invoke_void_return_wrapper<void>
#ifndef _LIBCPP_CXX03_LANG
template <class ..._Args>
static void __call(_Args&&... __args) {
__invoke(_VSTD::forward<_Args>(__args)...);
_VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
}
#else
template <class _Fn>
static void __call(_Fn __f) {
__invoke(__f);
_VSTD::__invoke(__f);
}

template <class _Fn, class _A0>
static void __call(_Fn __f, _A0& __a0) {
__invoke(__f, __a0);
_VSTD::__invoke(__f, __a0);
}

template <class _Fn, class _A0, class _A1>
static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
__invoke(__f, __a0, __a1);
_VSTD::__invoke(__f, __a0, __a1);
}

template <class _Fn, class _A0, class _A1, class _A2>
static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
__invoke(__f, __a0, __a1, __a2);
_VSTD::__invoke(__f, __a0, __a1, __a2);
}
#endif
};
Expand Down Expand Up @@ -398,112 +398,112 @@ public:
_LIBCPP_INLINE_VISIBILITY
typename __invoke_of<type&, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
}
#else

_LIBCPP_INLINE_VISIBILITY
typename __invoke_return<type>::type
operator() () const {
return __invoke(get());
return _VSTD::__invoke(get());
}

template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0>::type
operator() (_A0& __a0) const {
return __invoke(get(), __a0);
return _VSTD::__invoke(get(), __a0);
}

template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0 const>::type
operator() (_A0 const& __a0) const {
return __invoke(get(), __a0);
return _VSTD::__invoke(get(), __a0);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const {
return __invoke(get(), __a0, __a1);
return _VSTD::__invoke(get(), __a0, __a1);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1>::type
operator() (_A0 const& __a0, _A1& __a1) const {
return __invoke(get(), __a0, __a1);
return _VSTD::__invoke(get(), __a0, __a1);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1 const>::type
operator() (_A0& __a0, _A1 const& __a1) const {
return __invoke(get(), __a0, __a1);
return _VSTD::__invoke(get(), __a0, __a1);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1 const>::type
operator() (_A0 const& __a0, _A1 const& __a1) const {
return __invoke(get(), __a0, __a1);
return _VSTD::__invoke(get(), __a0, __a1);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2>::type
operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2>::type
operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2 const>::type
operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
return __invoke(get(), __a0, __a1, __a2);
return _VSTD::__invoke(get(), __a0, __a1, __a2);
}
#endif // _LIBCPP_CXX03_LANG
};
Expand Down
24 changes: 12 additions & 12 deletions libcxx/include/__functional_base_03
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct __enable_invoke_imp<_Ret, _T1, false, true> {
template <class _Ret, class _T1>
struct __enable_invoke_imp<_Ret, _T1, false, false> {
typedef typename add_lvalue_reference<
typename __apply_cv<decltype(*_VSTD::declval<_T1>()), _Ret>::type
typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
>::type _Bullet4;
typedef _Bullet4 type;
};
Expand Down Expand Up @@ -142,31 +142,31 @@ __invoke(_Fn __f, _T1& __t1) {

template <class _Fp>
inline _LIBCPP_INLINE_VISIBILITY
decltype(_VSTD::declval<_Fp&>()())
decltype(declval<_Fp&>()())
__invoke(_Fp& __f)
{
return __f();
}

template <class _Fp, class _A0>
inline _LIBCPP_INLINE_VISIBILITY
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>()))
decltype(declval<_Fp&>()(declval<_A0&>()))
__invoke(_Fp& __f, _A0& __a0)
{
return __f(__a0);
}

template <class _Fp, class _A0, class _A1>
inline _LIBCPP_INLINE_VISIBILITY
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>()))
decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
{
return __f(__a0, __a1);
}

template <class _Fp, class _A0, class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>()))
decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
{
return __f(__a0, __a1, __a2);
Expand All @@ -181,13 +181,13 @@ struct __invoke_return
template <class _Fp>
struct __invoke_return<_Fp, false>
{
typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type;
typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
};

template <class _Tp, class _A0>
struct __invoke_return0
{
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type;
typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
};

template <class _Rp, class _Tp, class _A0>
Expand All @@ -199,8 +199,8 @@ struct __invoke_return0<_Rp _Tp::*, _A0>
template <class _Tp, class _A0, class _A1>
struct __invoke_return1
{
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
_VSTD::declval<_A1&>())) type;
typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
declval<_A1&>())) type;
};

template <class _Rp, class _Class, class _A0, class _A1>
Expand All @@ -211,9 +211,9 @@ struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
template <class _Tp, class _A0, class _A1, class _A2>
struct __invoke_return2
{
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
_VSTD::declval<_A1&>(),
_VSTD::declval<_A2&>())) type;
typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
declval<_A1&>(),
declval<_A2&>())) type;
};

template <class _Ret, class _Class, class _A0, class _A1, class _A2>
Expand Down
36 changes: 18 additions & 18 deletions libcxx/include/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -3404,7 +3404,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
::new(__t) value_type(_VSTD::move(*__first));
::new ((void*)__t) value_type(_VSTD::move(*__first));
__d.template __incr<value_type>();
++__t;
_ForwardIterator __i = __first;
Expand All @@ -3417,7 +3417,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate
}
else
{
::new(__t) value_type(_VSTD::move(*__i));
::new ((void*)__t) value_type(_VSTD::move(*__i));
__d.template __incr<value_type>();
++__t;
}
Expand Down Expand Up @@ -3534,7 +3534,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
// Move the falses into the temporary buffer, and the trues to the front of the line
// Update __first to always point to the end of the trues
value_type* __t = __p.first;
::new(__t) value_type(_VSTD::move(*__first));
::new ((void*)__t) value_type(_VSTD::move(*__first));
__d.template __incr<value_type>();
++__t;
_BidirectionalIterator __i = __first;
Expand All @@ -3547,7 +3547,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last
}
else
{
::new(__t) value_type(_VSTD::move(*__i));
::new ((void*)__t) value_type(_VSTD::move(*__i));
__d.template __incr<value_type>();
++__t;
}
Expand Down Expand Up @@ -3922,23 +3922,23 @@ __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
value_type* __last2 = __first2;
::new(__last2) value_type(_VSTD::move(*__first1));
::new ((void*)__last2) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
for (++__last2; ++__first1 != __last1; ++__last2)
{
value_type* __j2 = __last2;
value_type* __i2 = __j2;
if (__comp(*__first1, *--__i2))
{
::new(__j2) value_type(_VSTD::move(*__i2));
::new ((void*)__j2) value_type(_VSTD::move(*__i2));
__d.template __incr<value_type>();
for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
*__j2 = _VSTD::move(*__i2);
*__j2 = _VSTD::move(*__first1);
}
else
{
::new(__j2) value_type(_VSTD::move(*__first1));
::new ((void*)__j2) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
}
}
Expand Down Expand Up @@ -4482,14 +4482,14 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
::new(__p) value_type(_VSTD::move(*__i));
::new ((void*)__p) value_type(_VSTD::move(*__i));
_VSTD::__half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
}
else
{
value_type* __p = __buff;
for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
::new(__p) value_type(_VSTD::move(*__i));
::new ((void*)__p) value_type(_VSTD::move(*__i));
typedef reverse_iterator<_BidirectionalIterator> _RBi;
typedef reverse_iterator<value_type*> _Rv;
_VSTD::__half_inplace_merge(_Rv(__p), _Rv(__buff),
Expand Down Expand Up @@ -4629,26 +4629,26 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
if (__first1 == __last1)
{
for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
::new (__result) value_type(_VSTD::move(*__first2));
::new ((void*)__result) value_type(_VSTD::move(*__first2));
__h.release();
return;
}
if (__first2 == __last2)
{
for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
::new (__result) value_type(_VSTD::move(*__first1));
::new ((void*)__result) value_type(_VSTD::move(*__first1));
__h.release();
return;
}
if (__comp(*__first2, *__first1))
{
::new (__result) value_type(_VSTD::move(*__first2));
::new ((void*)__result) value_type(_VSTD::move(*__first2));
__d.template __incr<value_type>();
++__first2;
}
else
{
::new (__result) value_type(_VSTD::move(*__first1));
::new ((void*)__result) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
++__first1;
}
Expand Down Expand Up @@ -4702,24 +4702,24 @@ __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1
case 0:
return;
case 1:
::new(__first2) value_type(_VSTD::move(*__first1));
::new ((void*)__first2) value_type(_VSTD::move(*__first1));
return;
case 2:
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
if (__comp(*--__last1, *__first1))
{
::new(__first2) value_type(_VSTD::move(*__last1));
::new ((void*)__first2) value_type(_VSTD::move(*__last1));
__d.template __incr<value_type>();
++__first2;
::new(__first2) value_type(_VSTD::move(*__first1));
::new ((void*)__first2) value_type(_VSTD::move(*__first1));
}
else
{
::new(__first2) value_type(_VSTD::move(*__first1));
::new ((void*)__first2) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
++__first2;
::new(__first2) value_type(_VSTD::move(*__last1));
::new ((void*)__first2) value_type(_VSTD::move(*__last1));
}
__h2.release();
return;
Expand Down
40 changes: 20 additions & 20 deletions libcxx/include/functional
Original file line number Diff line number Diff line change
Expand Up @@ -1296,106 +1296,106 @@ public:
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return<type, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
}
#else

template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0>::type
operator() (_A0& __a0) const {
return __invoke(__f_, __a0);
return _VSTD::__invoke(__f_, __a0);
}

template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type, _A0 const>::type
operator() (_A0 const& __a0) const {
return __invoke(__f_, __a0);
return _VSTD::__invoke(__f_, __a0);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const {
return __invoke(__f_, __a0, __a1);
return _VSTD::__invoke(__f_, __a0, __a1);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1>::type
operator() (_A0 const& __a0, _A1& __a1) const {
return __invoke(__f_, __a0, __a1);
return _VSTD::__invoke(__f_, __a0, __a1);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0, _A1 const>::type
operator() (_A0& __a0, _A1 const& __a1) const {
return __invoke(__f_, __a0, __a1);
return _VSTD::__invoke(__f_, __a0, __a1);
}

template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type, _A0 const, _A1 const>::type
operator() (_A0 const& __a0, _A1 const& __a1) const {
return __invoke(__f_, __a0, __a1);
return _VSTD::__invoke(__f_, __a0, __a1);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2>::type
operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2>::type
operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1, _A2 const>::type
operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}

template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
return _VSTD::__invoke(__f_, __a0, __a1, __a2);
}
#endif
};
Expand Down Expand Up @@ -1609,7 +1609,7 @@ public:
__builtin_new_allocator::__holder_t __hold =
__builtin_new_allocator::__allocate_type<__default_alloc_func>(1);
__default_alloc_func* __res =
::new (__hold.get()) __default_alloc_func(__f_);
::new ((void*)__hold.get()) __default_alloc_func(__f_);
(void)__hold.release();
return __res;
}
Expand Down Expand Up @@ -1700,7 +1700,7 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
{
::new (__p) __func(__f_.__target(), __f_.__get_allocator());
::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Expand Down Expand Up @@ -2154,7 +2154,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
} else {
__builtin_new_allocator::__holder_t __hold =
__builtin_new_allocator::__allocate_type<_Fun>(1);
__buf_.__large = ::new (__hold.get()) _Fun(_VSTD::move(__f));
__buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f));
(void)__hold.release();
}
}
Expand Down Expand Up @@ -2286,7 +2286,7 @@ public:
}

virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
::new (__p) __func(__f_);
::new ((void*)__p) __func(__f_);
}

virtual void destroy() _NOEXCEPT {
Expand All @@ -2303,7 +2303,7 @@ public:
}

virtual _Rp operator()(_ArgTypes&& ... __arg) {
return __invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI
Expand Down
20 changes: 10 additions & 10 deletions libcxx/include/future
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ __assoc_state<_Rp>::set_value(_Arg&& __arg)
unique_lock<mutex> __lk(this->__mut_);
if (this->__has_value())
__throw_future_error(future_errc::promise_already_satisfied);
::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed | base::ready;
__cv_.notify_all();
}
Expand All @@ -665,7 +665,7 @@ __assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg)
unique_lock<mutex> __lk(this->__mut_);
if (this->__has_value())
__throw_future_error(future_errc::promise_already_satisfied);
::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
::new ((void*)&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
}
Expand Down Expand Up @@ -1328,7 +1328,7 @@ promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0)
typedef __allocator_destructor<_A2> _D2;
_A2 __a(__a0);
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
__state_ = _VSTD::addressof(*__hold.release());
}

Expand Down Expand Up @@ -1471,7 +1471,7 @@ promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0)
typedef __allocator_destructor<_A2> _D2;
_A2 __a(__a0);
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
__state_ = _VSTD::addressof(*__hold.release());
}

Expand Down Expand Up @@ -1590,7 +1590,7 @@ promise<void>::promise(allocator_arg_t, const _Alloc& __a0)
typedef __allocator_destructor<_A2> _D2;
_A2 __a(__a0);
unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
::new(static_cast<void*>(_VSTD::addressof(*__hold.get()))) _State(__a0);
::new ((void*)_VSTD::addressof(*__hold.get())) _State(__a0);
__state_ = _VSTD::addressof(*__hold.release());
}

Expand Down Expand Up @@ -1655,7 +1655,7 @@ void
__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(
__packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT
{
::new (__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));
::new ((void*)__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));
}

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Expand Down Expand Up @@ -1748,7 +1748,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{
::new (&__buf_) _FF(_VSTD::forward<_Fp>(__f));
::new ((void*)&__buf_) _FF(_VSTD::forward<_Fp>(__f));
__f_ = (__base*)&__buf_;
}
else
Expand All @@ -1757,7 +1757,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));
::new ((void*)__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));
__f_ = __hold.release();
}
}
Expand All @@ -1773,15 +1773,15 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
::new (__f_) _FF(_VSTD::forward<_Fp>(__f));
::new ((void*)__f_) _FF(_VSTD::forward<_Fp>(__f));
}
else
{
typedef typename __allocator_traits_rebind<_Alloc, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
::new (static_cast<void*>(_VSTD::addressof(*__hold.get())))
::new ((void*)_VSTD::addressof(*__hold.get()))
_FF(_VSTD::forward<_Fp>(__f), _Alloc(__a));
__f_ = _VSTD::addressof(*__hold.release());
}
Expand Down
46 changes: 19 additions & 27 deletions libcxx/include/memory
Original file line number Diff line number Diff line change
Expand Up @@ -892,18 +892,13 @@ struct __rebind_pointer {

#if _LIBCPP_STD_VER > 17

template<class _Tp>
_LIBCPP_CONSTEXPR_AFTER_CXX17 void* __voidify(_Tp& __ptr) noexcept {
return const_cast<void*>(static_cast<const volatile void*>(_VSTD::addressof(__ptr)));
}

template<class _Tp, class ..._Args, class = decltype(
::new (_VSTD::declval<void*>()) _Tp(_VSTD::declval<_Args>()...)
::new (declval<void*>()) _Tp(declval<_Args>()...)
)>
_LIBCPP_INLINE_VISIBILITY
constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
_LIBCPP_ASSERT(__location, "null pointer given to construct_at");
return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
}

#endif
Expand Down Expand Up @@ -1617,7 +1612,7 @@ public:
template <class _Up, class... _Args>
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
void construct(_Up* __p, _Args&&... __args) {
::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
}

_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
Expand Down Expand Up @@ -1694,7 +1689,7 @@ public:
template <class _Up, class... _Args>
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
void construct(_Up* __p, _Args&&... __args) {
::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
}

_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
Expand Down Expand Up @@ -1813,10 +1808,10 @@ public:
_LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
{::new(_VSTD::addressof(*__x_)) _Tp(__element); return *this;}
{::new ((void*)_VSTD::addressof(*__x_)) _Tp(__element); return *this;}
#if _LIBCPP_STD_VER >= 14
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)
{::new(_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}
{::new ((void*)_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}
#endif
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)
Expand Down Expand Up @@ -2895,7 +2890,7 @@ uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
{
#endif
for (; __f != __l; ++__f, (void) ++__r)
::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand All @@ -2919,7 +2914,7 @@ uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
{
#endif
for (; __n > 0; ++__f, (void) ++__r, (void) --__n)
::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand All @@ -2943,7 +2938,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
{
#endif
for (; __f != __l; ++__f)
::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand All @@ -2966,7 +2961,7 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
{
#endif
for (; __n > 0; ++__f, (void) --__n)
::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -3005,7 +3000,7 @@ void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator
try {
#endif
for (; __idx != __last; ++__idx)
::new((void*)_VSTD::addressof(*__idx)) _Vt;
::new ((void*)_VSTD::addressof(*__idx)) _Vt;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
Expand All @@ -3023,7 +3018,7 @@ _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Si
try {
#endif
for (; __n > 0; (void)++__idx, --__n)
::new((void*)_VSTD::addressof(*__idx)) _Vt;
::new ((void*)_VSTD::addressof(*__idx)) _Vt;
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
Expand All @@ -3043,7 +3038,7 @@ void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __
try {
#endif
for (; __idx != __last; ++__idx)
::new((void*)_VSTD::addressof(*__idx)) _Vt();
::new ((void*)_VSTD::addressof(*__idx)) _Vt();
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
_VSTD::destroy(__first, __idx);
Expand All @@ -3061,7 +3056,7 @@ _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size
try {
#endif
for (; __n > 0; (void)++__idx, --__n)
::new((void*)_VSTD::addressof(*__idx)) _Vt();
::new ((void*)_VSTD::addressof(*__idx)) _Vt();
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
Expand All @@ -3081,7 +3076,7 @@ _ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __fi
try {
#endif
for (; __first != __last; (void)++__idx, ++__first)
::new((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
return __idx;
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
Expand All @@ -3101,7 +3096,7 @@ uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {
try {
#endif
for (; __n > 0; ++__idx, (void)++__first, --__n)
::new((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
return {__first, __idx};
#ifndef _LIBCPP_NO_EXCEPTIONS
} catch (...) {
Expand Down Expand Up @@ -3728,8 +3723,7 @@ shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
typedef __allocator_destructor<_A2> _D2;
_A2 __a2(__a);
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
_CntrlBlk(__p, __d, __a);
::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
__cntrl_ = _VSTD::addressof(*__hold2.release());
__enable_weak_this(__p, __p);
#ifndef _LIBCPP_NO_EXCEPTIONS
Expand All @@ -3756,8 +3750,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
typedef __allocator_destructor<_A2> _D2;
_A2 __a2(__a);
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
_CntrlBlk(__p, __d, __a);
::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
__cntrl_ = _VSTD::addressof(*__hold2.release());
#ifndef _LIBCPP_NO_EXCEPTIONS
}
Expand Down Expand Up @@ -4054,8 +4047,7 @@ allocate_shared(const _Alloc& __a, _Args&& ...__args)

_A2 __a2(__a);
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
_CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);

typename shared_ptr<_Tp>::element_type *__p = __hold2->__get_elem();
return shared_ptr<_Tp>::__create_with_control_block(__p, _VSTD::addressof(*__hold2.release()));
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/optional
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
void __construct(_Args&&... __args)
{
_LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
::new ((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
this->__engaged_ = true;
}

Expand Down
42 changes: 21 additions & 21 deletions libcxx/include/valarray
Original file line number Diff line number Diff line change
Expand Up @@ -2753,7 +2753,7 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
__r.__begin_ =
__r.__end_ = allocator<result_type>().allocate(__n);
for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
::new (__r.__end_) result_type(__expr_[__i]);
::new ((void*)__r.__end_) result_type(__expr_[__i]);
}
return __r;
}
Expand All @@ -2774,7 +2774,7 @@ valarray<_Tp>::valarray(size_t __n)
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
::new (__end_) value_type();
::new ((void*)__end_) value_type();
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -2808,7 +2808,7 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
::new (__end_) value_type(*__p);
::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand All @@ -2833,7 +2833,7 @@ valarray<_Tp>::valarray(const valarray& __v)
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
::new (__end_) value_type(*__p);
::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -2871,7 +2871,7 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il)
#endif // _LIBCPP_NO_EXCEPTIONS
size_t __n_left = __n;
for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
::new (__end_) value_type(*__p);
::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -2900,7 +2900,7 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
#endif // _LIBCPP_NO_EXCEPTIONS
size_t __n_left = __n;
for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
::new (__end_) value_type(*__p);
::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -2929,7 +2929,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
const value_type* __s = __ga.__vp_;
for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
__i != __e; ++__i, ++__end_)
::new (__end_) value_type(__s[*__i]);
::new ((void*)__end_) value_type(__s[*__i]);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -2958,7 +2958,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
const value_type* __s = __ma.__vp_;
for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
__i != __e; ++__i, ++__end_)
::new (__end_) value_type(__s[*__i]);
::new ((void*)__end_) value_type(__s[*__i]);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -2987,7 +2987,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
const value_type* __s = __ia.__vp_;
for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
__i != __e; ++__i, ++__end_)
::new (__end_) value_type(__s[*__i]);
::new ((void*)__end_) value_type(__s[*__i]);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down Expand Up @@ -3269,7 +3269,7 @@ valarray<_Tp>::operator+() const
{
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(+*__p);
::new ((void*)__r.__end_) value_type(+*__p);
}
return __r;
}
Expand All @@ -3284,7 +3284,7 @@ valarray<_Tp>::operator-() const
{
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(-*__p);
::new ((void*)__r.__end_) value_type(-*__p);
}
return __r;
}
Expand All @@ -3299,7 +3299,7 @@ valarray<_Tp>::operator~() const
{
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(~*__p);
::new ((void*)__r.__end_) value_type(~*__p);
}
return __r;
}
Expand All @@ -3314,7 +3314,7 @@ valarray<_Tp>::operator!() const
{
__r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) bool(!*__p);
::new ((void*)__r.__end_) bool(!*__p);
}
return __r;
}
Expand Down Expand Up @@ -3649,11 +3649,11 @@ valarray<_Tp>::shift(int __i) const
__te = __r.__begin_ + __n;
}
for (; __r.__end_ != __tb; ++__r.__end_)
::new (__r.__end_) value_type();
::new ((void*)__r.__end_) value_type();
for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
::new (__r.__end_) value_type(*__sb);
::new ((void*)__r.__end_) value_type(*__sb);
for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
::new (__r.__end_) value_type();
::new ((void*)__r.__end_) value_type();
}
return __r;
}
Expand All @@ -3670,9 +3670,9 @@ valarray<_Tp>::cshift(int __i) const
__i %= static_cast<int>(__n);
const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
::new (__r.__end_) value_type(*__s);
::new ((void*)__r.__end_) value_type(*__s);
for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
::new (__r.__end_) value_type(*__s);
::new ((void*)__r.__end_) value_type(*__s);
}
return __r;
}
Expand All @@ -3687,7 +3687,7 @@ valarray<_Tp>::apply(value_type __f(value_type)) const
{
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(__f(*__p));
::new ((void*)__r.__end_) value_type(__f(*__p));
}
return __r;
}
Expand All @@ -3702,7 +3702,7 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const
{
__r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(__f(*__p));
::new ((void*)__r.__end_) value_type(__f(*__p));
}
return __r;
}
Expand Down Expand Up @@ -3733,7 +3733,7 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
::new (__end_) value_type(__x);
::new ((void*)__end_) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Expand Down
35 changes: 35 additions & 0 deletions libcxx/test/std/algorithms/robust_against_adl_on_new.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// 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

// <algorithm>

#include <algorithm>

#include "test_macros.h"

struct A {
int i;
A(int v) : i(v) {}
bool operator<(const A& rhs) const { return i < rhs.i; }
static bool isEven(const A& a) { return a.i % 2 == 0; }
};

void *operator new(size_t, A*) = delete;

int main(int, char**)
{
A a[4] = { 1,2,3,4 };
std::sort(a, a+4);
std::partition(a, a+4, A::isEven);
std::stable_sort(a, a+4);
std::stable_partition(a, a+4, A::isEven);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// <functional>

#include <functional>

#include "test_macros.h"

struct Incomplete;
template<class T> struct Holder { T t; };
typedef Holder<Incomplete> *Ptr;

struct A {
Ptr no_args() const { return nullptr; }
Ptr one_arg(Ptr p) const { return p; }
void one_arg_void(Ptr) const { }
};

int main(int, char**)
{
A a;
A *pa = &a;
const A *cpa = &a;
Ptr x = nullptr;
const Ptr cx = nullptr;
std::mem_fn(&A::no_args)(a);
std::mem_fn(&A::no_args)(pa);
std::mem_fn(&A::no_args)(*cpa);
std::mem_fn(&A::no_args)(cpa);
std::mem_fn(&A::one_arg)(a, x);
std::mem_fn(&A::one_arg)(pa, x);
std::mem_fn(&A::one_arg)(a, cx);
std::mem_fn(&A::one_arg)(pa, cx);
std::mem_fn(&A::one_arg)(*cpa, x);
std::mem_fn(&A::one_arg)(cpa, x);
std::mem_fn(&A::one_arg)(*cpa, cx);
std::mem_fn(&A::one_arg)(cpa, cx);
std::mem_fn(&A::one_arg_void)(a, x);
std::mem_fn(&A::one_arg_void)(pa, x);
std::mem_fn(&A::one_arg_void)(a, cx);
std::mem_fn(&A::one_arg_void)(pa, cx);
std::mem_fn(&A::one_arg_void)(*cpa, x);
std::mem_fn(&A::one_arg_void)(cpa, x);
std::mem_fn(&A::one_arg_void)(*cpa, cx);
std::mem_fn(&A::one_arg_void)(cpa, cx);
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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

// <functional>

#include <functional>

#include "test_macros.h"

struct Incomplete;
template<class T> struct Holder { T t; };
typedef Holder<Incomplete> *Ptr;

Ptr no_args() { return nullptr; }
Ptr one_arg(Ptr p) { return p; }
Ptr two_args(Ptr p, Ptr) { return p; }
Ptr three_args(Ptr p, Ptr, Ptr) { return p; }
Ptr four_args(Ptr p, Ptr, Ptr, Ptr) { return p; }

void one_arg_void(Ptr) { }

int main(int, char**)
{
Ptr x = nullptr;
std::function<Ptr()> f(no_args); f();
std::function<Ptr(Ptr)> g(one_arg); g(x);
std::function<void(Ptr)> h(one_arg_void); h(x);
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// <functional>

#include <functional>

#include "test_macros.h"

struct Incomplete;
template<class T> struct Holder { T t; };
typedef Holder<Incomplete> *Ptr;

Ptr no_args() { return nullptr; }
Ptr one_arg(Ptr p) { return p; }
Ptr two_args(Ptr p, Ptr) { return p; }
Ptr three_args(Ptr p, Ptr, Ptr) { return p; }

void one_arg_void(Ptr) { }

int main(int, char**)
{
Ptr x = nullptr;
const Ptr cx = nullptr;
std::ref(no_args)();
std::ref(one_arg)(x);
std::ref(one_arg)(cx);
std::ref(two_args)(x, x);
std::ref(two_args)(x, cx);
std::ref(two_args)(cx, x);
std::ref(two_args)(cx, cx);
std::ref(three_args)(x, x, x);
std::ref(three_args)(x, x, cx);
std::ref(three_args)(x, cx, x);
std::ref(three_args)(cx, x, x);
std::ref(three_args)(x, cx, cx);
std::ref(three_args)(cx, x, cx);
std::ref(three_args)(cx, cx, x);
std::ref(three_args)(cx, cx, cx);
std::ref(one_arg_void)(x);
std::ref(one_arg_void)(cx);

return 0;
}