| 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 | |
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | # pragma GCC system_header |
| 16 | #endif |
| 17 | |
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | template <class _Tp> |
| 20 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { |
| 21 | // The compiler diagnoses misuses of __builtin_launder, so we don't need to add any static_asserts |
| 22 | // to implement the Mandates. |
| 23 | return __builtin_launder(__p); |
| 24 | } |
| 25 | |
| 26 | #if _LIBCPP_STD_VER >= 17 |
| 27 | template <class _Tp> |
| 28 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { |
| 29 | return __builtin_launder(__p); |
| 30 | } |
| 31 | #endif |
| 32 | _LIBCPP_END_NAMESPACE_STD |
| 33 | |
| 34 | #endif // _LIBCPP___NEW_LAUNDER_H |
| 35 | |