Warning, file /include/QtCore/q23utility.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003 #ifndef Q23UTILITY_H
0004 #define Q23UTILITY_H
0005
0006 #include <QtCore/qtconfigmacros.h>
0007
0008 #include <utility>
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 QT_BEGIN_NAMESPACE
0027
0028 namespace q23 {
0029
0030 #ifdef __cpp_lib_forward_like
0031 using std::forward_like;
0032 #else
0033
0034 namespace _detail {
0035
0036
0037 template <typename A, typename B>
0038 using copy_const_t = std::conditional_t<
0039 std::is_const_v<A>, const B,
0040 B
0041 >;
0042
0043
0044 template <typename A, typename B>
0045 using override_ref_t = std::conditional_t<
0046 std::is_rvalue_reference_v<A>, std::remove_reference_t<B>&&,
0047 B&
0048 >;
0049
0050
0051 template <typename T, typename U>
0052 using forward_like_ret_t = override_ref_t<
0053 T&&,
0054 copy_const_t<
0055 std::remove_reference_t<T>,
0056 std::remove_reference_t<U>
0057 >
0058 >;
0059
0060 }
0061
0062
0063 template <class T, class U>
0064 [[nodiscard]] constexpr auto forward_like(U &&x) noexcept
0065 -> _detail::forward_like_ret_t<T, U>
0066 {
0067 using V = _detail::forward_like_ret_t<T, U>;
0068 return static_cast<V>(x);
0069 }
0070 #endif
0071 }
0072
0073 QT_END_NAMESPACE
0074
0075 #endif