xref: /freebsd/contrib/llvm-project/libcxx/include/__type_traits/add_pointer.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
10 #define _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
11 
12 #include <__config>
13 #include <__type_traits/is_referenceable.h>
14 #include <__type_traits/is_void.h>
15 #include <__type_traits/remove_reference.h>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #  pragma GCC system_header
19 #endif
20 
21 _LIBCPP_BEGIN_NAMESPACE_STD
22 
23 #if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
24 
25 template <class _Tp>
26 using __add_pointer_t = __add_pointer(_Tp);
27 
28 #else
29 template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>
30 struct __add_pointer_impl {
31   typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp>* type;
32 };
33 template <class _Tp>
34 struct __add_pointer_impl<_Tp, false> {
35   typedef _LIBCPP_NODEBUG _Tp type;
36 };
37 
38 template <class _Tp>
39 using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
40 
41 #endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
42 
43 template <class _Tp>
44 struct add_pointer {
45   using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
46 };
47 
48 #if _LIBCPP_STD_VER >= 14
49 template <class _Tp>
50 using add_pointer_t = __add_pointer_t<_Tp>;
51 #endif
52 
53 _LIBCPP_END_NAMESPACE_STD
54 
55 #endif // _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
56