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___NEW_LAUNDER_H 10 #define _LIBCPP___NEW_LAUNDER_H 11 12 #include <__config> 13 #include <__type_traits/is_function.h> 14 #include <__type_traits/is_void.h> 15 16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17 # pragma GCC system_header 18 #endif 19 20 _LIBCPP_BEGIN_NAMESPACE_STD 21 template <class _Tp> 22 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { 23 static_assert(!(is_function<_Tp>::value), "can't launder functions"); 24 static_assert(!is_void<_Tp>::value, "can't launder cv-void"); 25 return __builtin_launder(__p); 26 } 27 28 #if _LIBCPP_STD_VER >= 17 29 template <class _Tp> 30 [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { 31 return std::__launder(__p); 32 } 33 #endif 34 _LIBCPP_END_NAMESPACE_STD 35 36 #endif // _LIBCPP___NEW_LAUNDER_H 37