From a709c823f75046fa9c0c03e6177c7b2fe7a30915 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Thu, 8 Aug 2013 03:06:24 +0000 Subject: [PATCH] Revert r187927. Zhihao Yuan: Replace operator& with addressof in reference_wrapper constructor. It breaks a clang bootstrap. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@187959 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__functional_base | 53 +-------------------------------------- include/memory | 50 +++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 53 deletions(-) diff --git a/include/__functional_base b/include/__functional_base index 800b4b929..2bc2d2c14 100644 --- a/include/__functional_base +++ b/include/__functional_base @@ -365,56 +365,6 @@ struct __invoke_return typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; }; -// addressof - -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp* -addressof(_Tp& __x) _NOEXCEPT -{ - return (_Tp*)&reinterpret_cast(__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 -inline _LIBCPP_INLINE_VISIBILITY -__strong _Tp* -addressof(__strong _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK -template -inline _LIBCPP_INLINE_VISIBILITY -__weak _Tp* -addressof(__weak _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -__autoreleasing _Tp* -addressof(__autoreleasing _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__unsafe_unretained _Tp* -addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif - template class _LIBCPP_TYPE_VIS reference_wrapper : public __weak_result_type<_Tp> @@ -427,8 +377,7 @@ private: public: // construct/copy/destroy - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT - : __f_(_VSTD::addressof(__f)) {} + _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT : __f_(&__f) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES private: reference_wrapper(type&&); public: // = delete; // do not bind to temps #endif diff --git a/include/memory b/include/memory index 8e14a640d..ffd0cd0ce 100644 --- a/include/memory +++ b/include/memory @@ -618,7 +618,55 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); _LIBCPP_BEGIN_NAMESPACE_STD -// addressof moved to <__functional_base> +// addressof + +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return (_Tp*)&reinterpret_cast(__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 +inline _LIBCPP_INLINE_VISIBILITY +__strong _Tp* +addressof(__strong _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK +template +inline _LIBCPP_INLINE_VISIBILITY +__weak _Tp* +addressof(__weak _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +__autoreleasing _Tp* +addressof(__autoreleasing _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +__unsafe_unretained _Tp* +addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif template class allocator;