Path: blob/main/contrib/llvm-project/libcxx/include/__utility/forward_like.h
35235 views
// -*- 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//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___UTILITY_FORWARD_LIKE_H10#define _LIBCPP___UTILITY_FORWARD_LIKE_H1112#include <__config>13#include <__type_traits/conditional.h>14#include <__type_traits/is_const.h>15#include <__type_traits/is_reference.h>16#include <__type_traits/remove_reference.h>1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19# pragma GCC system_header20#endif2122_LIBCPP_BEGIN_NAMESPACE_STD2324#if _LIBCPP_STD_VER >= 232526template <class _Ap, class _Bp>27using _CopyConst = _If<is_const_v<_Ap>, const _Bp, _Bp>;2829template <class _Ap, class _Bp>30using _OverrideRef = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>;3132template <class _Ap, class _Bp>33using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;3435template <class _Tp, class _Up>36[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto37forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up> {38return static_cast<_ForwardLike<_Tp, _Up>>(__ux);39}4041#endif // _LIBCPP_STD_VER >= 234243_LIBCPP_END_NAMESPACE_STD4445#endif // _LIBCPP___UTILITY_FORWARD_LIKE_H464748