forked from OSchip/llvm-project
My previous reorganization of addressof broke -std=c++03. Thanks much to Arnold Schwaighofer for catching this. This patch also catches a few more missing addressof in <future>, thanks go to Zhihao Yuan for catching these.
llvm-svn: 187997
This commit is contained in:
parent
9ba6eaec57
commit
8c9742051d
|
@ -71,6 +71,56 @@ struct _LIBCPP_TYPE_VIS less<void>
|
|||
};
|
||||
#endif
|
||||
|
||||
// addressof
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp*
|
||||
addressof(_Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
|
||||
// Objective-C++ Automatic Reference Counting uses qualified pointers
|
||||
// that require special addressof() signatures. When
|
||||
// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
|
||||
// itself is providing these definitions. Otherwise, we provide them.
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__strong _Tp*
|
||||
addressof(__strong _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__weak _Tp*
|
||||
addressof(__weak _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__autoreleasing _Tp*
|
||||
addressof(__autoreleasing _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__unsafe_unretained _Tp*
|
||||
addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#include <__functional_base_03>
|
||||
|
@ -377,7 +427,8 @@ private:
|
|||
|
||||
public:
|
||||
// construct/copy/destroy
|
||||
_LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT : __f_(&__f) {}
|
||||
_LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
|
||||
: __f_(_VSTD::addressof(__f)) {}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
|
||||
#endif
|
||||
|
|
|
@ -727,7 +727,7 @@ __assoc_state<_Rp&>::set_value(_Rp& __arg)
|
|||
if (this->__has_value())
|
||||
throw future_error(make_error_code(future_errc::promise_already_satisfied));
|
||||
#endif
|
||||
__value_ = &__arg;
|
||||
__value_ = _VSTD::addressof(__arg);
|
||||
this->__state_ |= base::__constructed | base::ready;
|
||||
__lk.unlock();
|
||||
__cv_.notify_all();
|
||||
|
@ -742,7 +742,7 @@ __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg)
|
|||
if (this->__has_value())
|
||||
throw future_error(make_error_code(future_errc::promise_already_satisfied));
|
||||
#endif
|
||||
__value_ = &__arg;
|
||||
__value_ = _VSTD::addressof(__arg);
|
||||
this->__state_ |= base::__constructed;
|
||||
__thread_local_data()->__make_ready_at_thread_exit(this);
|
||||
__lk.unlock();
|
||||
|
@ -778,7 +778,7 @@ void
|
|||
__assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT
|
||||
{
|
||||
if (this->__state_ & base::__constructed)
|
||||
reinterpret_cast<_Rp*>(&this->__value_)->~_Rp();
|
||||
reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp();
|
||||
typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_);
|
||||
this->~__assoc_state_alloc();
|
||||
__a.deallocate(this, 1);
|
||||
|
|
|
@ -618,55 +618,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
|
|||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// addressof
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp*
|
||||
addressof(_Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
|
||||
// Objective-C++ Automatic Reference Counting uses qualified pointers
|
||||
// that require special addressof() signatures. When
|
||||
// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
|
||||
// itself is providing these definitions. Otherwise, we provide them.
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__strong _Tp*
|
||||
addressof(__strong _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__weak _Tp*
|
||||
addressof(__weak _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__autoreleasing _Tp*
|
||||
addressof(__autoreleasing _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__unsafe_unretained _Tp*
|
||||
addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
|
||||
{
|
||||
return &__x;
|
||||
}
|
||||
#endif
|
||||
// addressof moved to <__functional_base>
|
||||
|
||||
template <class _Tp> class allocator;
|
||||
|
||||
|
|
Loading…
Reference in New Issue