File indexing completed on 2026-07-26 09:20:17
0001
0002
0003
0004 #ifndef Q23UTILITY_H
0005 #define Q23UTILITY_H
0006
0007 #include <QtCore/qtconfigmacros.h>
0008
0009 #include <QtCore/q20utility.h>
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 QT_BEGIN_NAMESPACE
0028
0029 namespace q23 {
0030
0031 #ifdef __cpp_lib_forward_like
0032 using std::forward_like;
0033 #else
0034
0035 namespace _detail {
0036
0037
0038 template <typename A, typename B>
0039 using copy_const_t = std::conditional_t<
0040 std::is_const_v<A>, const B,
0041 B
0042 >;
0043
0044
0045 template <typename A, typename B>
0046 using override_ref_t = std::conditional_t<
0047 std::is_rvalue_reference_v<A>, std::remove_reference_t<B>&&,
0048 B&
0049 >;
0050
0051
0052 template <typename T, typename U>
0053 using forward_like_ret_t = override_ref_t<
0054 T&&,
0055 copy_const_t<
0056 std::remove_reference_t<T>,
0057 std::remove_reference_t<U>
0058 >
0059 >;
0060
0061 }
0062
0063
0064 template <class T, class U>
0065 [[nodiscard]] constexpr auto forward_like(U &&x) noexcept
0066 -> _detail::forward_like_ret_t<T, U>
0067 {
0068 using V = _detail::forward_like_ret_t<T, U>;
0069 return static_cast<V>(x);
0070 }
0071 #endif
0072 }
0073
0074 QT_END_NAMESPACE
0075
0076 #endif