35 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___NEW_LAUNDER_H10#define _LIBCPP___NEW_LAUNDER_H11 12#include <__config>13 14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15# pragma GCC system_header16#endif17 18_LIBCPP_BEGIN_NAMESPACE_STD19template <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_asserts22 // to implement the Mandates.23 return __builtin_launder(__p);24}25 26#if _LIBCPP_STD_VER >= 1727template <class _Tp>28[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept {29 return __builtin_launder(__p);30}31#endif32_LIBCPP_END_NAMESPACE_STD33 34#endif // _LIBCPP___NEW_LAUNDER_H35