Back to home page

EIC code displayed by LXR

 
 

    


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 // Copyright (C) 2023 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 #ifndef Q23UTILITY_H
0004 #define Q23UTILITY_H
0005 
0006 #include <QtCore/qtconfigmacros.h>
0007 
0008 #include <utility>
0009 
0010 //
0011 //  W A R N I N G
0012 //  -------------
0013 //
0014 // This file is not part of the Qt API. Types and functions defined in this
0015 // file can reliably be replaced by their std counterparts, once available.
0016 // You may use these definitions in your own code, but be aware that we
0017 // will remove them once Qt depends on the C++ version that supports
0018 // them in namespace std. There will be NO deprecation warning, the
0019 // definitions will JUST go away.
0020 //
0021 // If you can't agree to these terms, don't use these definitions!
0022 //
0023 // We mean it.
0024 //
0025 
0026 QT_BEGIN_NAMESPACE
0027 
0028 namespace q23 {
0029 // like std::forward_like
0030 #ifdef __cpp_lib_forward_like
0031 using std::forward_like;
0032 #else
0033 
0034 namespace _detail {
0035 
0036 // [forward]/6.1 COPY_CONST
0037 template <typename A, typename B>
0038 using copy_const_t = std::conditional_t<
0039         std::is_const_v<A>, const B,
0040         /* else */          B
0041     >;
0042 
0043 // [forward]/6.2 OVERRIDE_REF
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         /* else */                     B&
0048     >;
0049 
0050 // [forward]/6.3 "V"
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 } // namespace detail
0061 
0062 // http://eel.is/c++draft/forward#lib:forward_like
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 // __cpp_lib_forward_like
0071 } // namespace q23
0072 
0073 QT_END_NAMESPACE
0074 
0075 #endif /* Q23UTILITY_H */