File indexing completed on 2026-05-03 08:13:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___UTILITY_FORWARD_LIKE_H
0011 #define _LIBCPP___CXX03___UTILITY_FORWARD_LIKE_H
0012
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__type_traits/conditional.h>
0015 #include <__cxx03/__type_traits/is_const.h>
0016 #include <__cxx03/__type_traits/is_reference.h>
0017 #include <__cxx03/__type_traits/remove_reference.h>
0018
0019 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0020 # pragma GCC system_header
0021 #endif
0022
0023 _LIBCPP_BEGIN_NAMESPACE_STD
0024
0025 #if _LIBCPP_STD_VER >= 23
0026
0027 template <class _Ap, class _Bp>
0028 using _CopyConst = _If<is_const_v<_Ap>, const _Bp, _Bp>;
0029
0030 template <class _Ap, class _Bp>
0031 using _OverrideRef = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>;
0032
0033 template <class _Ap, class _Bp>
0034 using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;
0035
0036 template <class _Tp, class _Up>
0037 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto
0038 forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up> {
0039 return static_cast<_ForwardLike<_Tp, _Up>>(__ux);
0040 }
0041
0042 #endif
0043
0044 _LIBCPP_END_NAMESPACE_STD
0045
0046 #endif