Everywhere, normalize the whitespace to `::new (EXPR) T`.
Everywhere, normalize the spelling of the cast to `(void*)EXPR`.
Without the cast to `(void*)`, the expression triggers ADL on GCC.
(I think this is a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98249)
Even if it doesn't trigger ADL, it still seems incorrect to use any argument
that's not exactly `(void*)` because that opens the possibility of overload
resolution picking a user-defined overload of `operator new`, which would be
wrong.
Differential Revision: https://reviews.llvm.org/D93153
template <class _Cont>
_LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {
- return ::new(__mem) _C_node<_Cont>(__c, __next);
+ return ::new (__mem) _C_node<_Cont>(__c, __next);
}
template <class _Cont>
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
void
__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp>
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
void
__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp, class _A0>
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
void
__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+ ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
return __hold.release();
}
void
__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
{
- ::new (__p) __func(__f_.first(), __f_.second());
+ ::new ((void*)__p) __func(__f_.first(), __f_.second());
}
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f);
+ ::new ((void*)__f_) _FF(__f);
}
else
{
_Ap __a;
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+ ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
__f_ = __hold.release();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(__f, __a0);
+ ::new ((void*)__f_) _FF(__f, __a0);
}
else
{
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new (__hold.get()) _FF(__f, _Alloc(__a));
+ ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
__f_ = __hold.release();
}
}
// 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;
}
else
{
- ::new(__t) value_type(_VSTD::move(*__i));
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
__d.template __incr<value_type>();
++__t;
}
// 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;
}
else
{
- ::new(__t) value_type(_VSTD::move(*__i));
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
__d.template __incr<value_type>();
++__t;
}
__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* __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);
}
else
{
- ::new(__j2) value_type(_VSTD::move(*__first1));
+ ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
__d.template __incr<value_type>();
}
}
{
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),
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;
}
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;
__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;
}
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>
} 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();
}
}
}
virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
- ::new (__p) __func(__f_);
+ ::new ((void*)__p) __func(__f_);
}
virtual void destroy() _NOEXCEPT {
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();
}
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);
}
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());
}
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());
}
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());
}
__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>
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
_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();
}
}
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
- ::new (__f_) _FF(_VSTD::forward<_Fp>(__f));
+ ::new ((void*)__f_) _FF(_VSTD::forward<_Fp>(__f));
}
else
{
_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());
}
#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
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
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
_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)
{
#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 (...)
{
#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 (...)
{
#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 (...)
{
#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 (...)
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);
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 (...) {
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);
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 (...) {
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 (...) {
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 (...) {
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
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
}
_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()));
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;
}
__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;
}
{
#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 (...)
{
#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 (...)
{
#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 (...)
#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 (...)
#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 (...)
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 (...)
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 (...)
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 (...)
{
__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;
}
{
__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;
}
{
__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;
}
{
__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;
}
__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;
}
__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;
}
{
__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;
}
{
__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;
}
{
#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 (...)
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}