File indexing completed on 2026-05-03 08:14:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___UTILITY_FORWARD_LIKE_H
0011 #define _LIBCPP___UTILITY_FORWARD_LIKE_H
0012
0013 #include <__config>
0014 #include <__type_traits/conditional.h>
0015 #include <__type_traits/is_base_of.h>
0016 #include <__type_traits/is_const.h>
0017 #include <__type_traits/is_reference.h>
0018 #include <__type_traits/remove_reference.h>
0019
0020 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 # pragma GCC system_header
0022 #endif
0023
0024 _LIBCPP_BEGIN_NAMESPACE_STD
0025
0026 #if _LIBCPP_STD_VER >= 23
0027
0028 template <class _Ap, class _Bp>
0029 using _CopyConst _LIBCPP_NODEBUG = _If<is_const_v<_Ap>, const _Bp, _Bp>;
0030
0031 template <class _Ap, class _Bp>
0032 using _OverrideRef _LIBCPP_NODEBUG = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>;
0033
0034 template <class _Ap, class _Bp>
0035 using _ForwardLike _LIBCPP_NODEBUG = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;
0036
0037 template <class _Tp, class _Up>
0038 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto
0039 forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up> {
0040 return static_cast<_ForwardLike<_Tp, _Up>>(__ux);
0041 }
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 template <class _Tp, class _As, class _Up>
0053 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _ForwardLike<_Tp, _As>
0054 __forward_as(_LIBCPP_LIFETIMEBOUND _Up&& __val) noexcept {
0055 static_assert(is_base_of_v<_As, remove_reference_t<_Up>>);
0056 return static_cast<_ForwardLike<_Tp, _As>>(__val);
0057 }
0058
0059 #endif
0060
0061 _LIBCPP_END_NAMESPACE_STD
0062
0063 #endif