1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___NEW_LAUNDER_H
10 #define _LIBCPP___NEW_LAUNDER_H
13 #include <__type_traits/is_function.h>
14 #include <__type_traits/is_void.h>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # pragma GCC system_header
20 _LIBCPP_BEGIN_NAMESPACE_STD
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
);
28 #if _LIBCPP_STD_VER >= 17
30 [[nodiscard
]] inline _LIBCPP_HIDE_FROM_ABI
constexpr _Tp
* launder(_Tp
* __p
) noexcept
{
31 return std::__launder(__p
);
34 _LIBCPP_END_NAMESPACE_STD
36 #endif // _LIBCPP___NEW_LAUNDER_H