2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___MEMORY_ADDRESSOF_H
11 #define _LIBCPP___MEMORY_ADDRESSOF_H
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 #pragma GCC system_header
19 _LIBCPP_BEGIN_NAMESPACE_STD
22 inline _LIBCPP_CONSTEXPR_AFTER_CXX14
23 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
25 addressof(_Tp
& __x
) _NOEXCEPT
27 return __builtin_addressof(__x
);
30 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
31 // Objective-C++ Automatic Reference Counting uses qualified pointers
32 // that require special addressof() signatures. When
33 // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
34 // itself is providing these definitions. Otherwise, we provide them.
36 inline _LIBCPP_INLINE_VISIBILITY
38 addressof(__strong _Tp
& __x
) _NOEXCEPT
43 #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
45 inline _LIBCPP_INLINE_VISIBILITY
47 addressof(__weak _Tp
& __x
) _NOEXCEPT
54 inline _LIBCPP_INLINE_VISIBILITY
56 addressof(__autoreleasing _Tp
& __x
) _NOEXCEPT
62 inline _LIBCPP_INLINE_VISIBILITY
63 __unsafe_unretained _Tp
*
64 addressof(__unsafe_unretained _Tp
& __x
) _NOEXCEPT
70 #if !defined(_LIBCPP_CXX03_LANG)
71 template <class _Tp
> _Tp
* addressof(const _Tp
&&) noexcept
= delete;
74 _LIBCPP_END_NAMESPACE_STD
76 #endif // _LIBCPP___MEMORY_ADDRESSOF_H