Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / include / __memory / addressof.h
blob98b08958a6a93ebe5e0072ea778b83e72e30c42f
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
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
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___MEMORY_ADDRESSOF_H
11 #define _LIBCPP___MEMORY_ADDRESSOF_H
13 #include <__config>
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 # pragma GCC system_header
17 #endif
19 _LIBCPP_BEGIN_NAMESPACE_STD
21 template <class _Tp>
22 inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* addressof(_Tp& __x) _NOEXCEPT {
23 return __builtin_addressof(__x);
26 #if _LIBCPP_HAS_OBJC_ARC
27 // Objective-C++ Automatic Reference Counting uses qualified pointers
28 // that require special addressof() signatures.
29 template <class _Tp>
30 inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEPT {
31 return &__x;
34 # if _LIBCPP_HAS_OBJC_ARC_WEAK
35 template <class _Tp>
36 inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT {
37 return &__x;
39 # endif
41 template <class _Tp>
42 inline _LIBCPP_HIDE_FROM_ABI __autoreleasing _Tp* addressof(__autoreleasing _Tp& __x) _NOEXCEPT {
43 return &__x;
46 template <class _Tp>
47 inline _LIBCPP_HIDE_FROM_ABI __unsafe_unretained _Tp* addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT {
48 return &__x;
50 #endif
52 #if !defined(_LIBCPP_CXX03_LANG)
53 template <class _Tp>
54 _Tp* addressof(const _Tp&&) noexcept = delete;
55 #endif
57 _LIBCPP_END_NAMESPACE_STD
59 #endif // _LIBCPP___MEMORY_ADDRESSOF_H