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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187997 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a709c823f7
commit
a4e87abbb9
@ -71,6 +71,56 @@ struct _LIBCPP_TYPE_VIS less<void>
|
|||||||
};
|
};
|
||||||
#endif
|
#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
|
#ifdef _LIBCPP_HAS_NO_VARIADICS
|
||||||
|
|
||||||
#include <__functional_base_03>
|
#include <__functional_base_03>
|
||||||
@ -377,7 +427,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// construct/copy/destroy
|
// 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
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
|
private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
|
||||||
#endif
|
#endif
|
||||||
|
@ -727,7 +727,7 @@ __assoc_state<_Rp&>::set_value(_Rp& __arg)
|
|||||||
if (this->__has_value())
|
if (this->__has_value())
|
||||||
throw future_error(make_error_code(future_errc::promise_already_satisfied));
|
throw future_error(make_error_code(future_errc::promise_already_satisfied));
|
||||||
#endif
|
#endif
|
||||||
__value_ = &__arg;
|
__value_ = _VSTD::addressof(__arg);
|
||||||
this->__state_ |= base::__constructed | base::ready;
|
this->__state_ |= base::__constructed | base::ready;
|
||||||
__lk.unlock();
|
__lk.unlock();
|
||||||
__cv_.notify_all();
|
__cv_.notify_all();
|
||||||
@ -742,7 +742,7 @@ __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg)
|
|||||||
if (this->__has_value())
|
if (this->__has_value())
|
||||||
throw future_error(make_error_code(future_errc::promise_already_satisfied));
|
throw future_error(make_error_code(future_errc::promise_already_satisfied));
|
||||||
#endif
|
#endif
|
||||||
__value_ = &__arg;
|
__value_ = _VSTD::addressof(__arg);
|
||||||
this->__state_ |= base::__constructed;
|
this->__state_ |= base::__constructed;
|
||||||
__thread_local_data()->__make_ready_at_thread_exit(this);
|
__thread_local_data()->__make_ready_at_thread_exit(this);
|
||||||
__lk.unlock();
|
__lk.unlock();
|
||||||
@ -778,7 +778,7 @@ void
|
|||||||
__assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT
|
__assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT
|
||||||
{
|
{
|
||||||
if (this->__state_ & base::__constructed)
|
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_);
|
typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_);
|
||||||
this->~__assoc_state_alloc();
|
this->~__assoc_state_alloc();
|
||||||
__a.deallocate(this, 1);
|
__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
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||||
|
|
||||||
// addressof
|
// addressof moved to <__functional_base>
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
template <class _Tp> class allocator;
|
template <class _Tp> class allocator;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user