Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
q23utility.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef Q23UTILITY_H
4#define Q23UTILITY_H
5
6#include <QtCore/qtconfigmacros.h>
7
8#include <QtCore/q20utility.h>
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. Types and functions defined in this
15// file can reliably be replaced by their std counterparts, once available.
16// You may use these definitions in your own code, but be aware that we
17// will remove them once Qt depends on the C++ version that supports
18// them in namespace std. There will be NO deprecation warning, the
19// definitions will JUST go away.
20//
21// If you can't agree to these terms, don't use these definitions!
22//
23// We mean it.
24//
25
26QT_BEGIN_NAMESPACE
27
28namespace q23 {
29// like std::forward_like
30#ifdef __cpp_lib_forward_like
31using std::forward_like;
32#else
33
34namespace _detail {
35
36// [forward]/6.1 COPY_CONST
37template <typename A, typename B>
39 std::is_const_v<A>, const B,
40 /* else */ B
41 >;
42
43// [forward]/6.2 OVERRIDE_REF
44template <typename A, typename B>
47 /* else */ B&
48 >;
49
50// [forward]/6.3 "V"
51template <typename T, typename U>
53 T&&,
57 >
58 >;
59
60} // namespace detail
61
62// http://eel.is/c++draft/forward#lib:forward_like
63template <class T, class U>
64[[nodiscard]] constexpr auto forward_like(U &&x) noexcept
66{
67 using V = _detail::forward_like_ret_t<T, U>;
68 return static_cast<V>(x);
69}
70#endif // __cpp_lib_forward_like
71} // namespace q23
72
73QT_END_NAMESPACE
74
75#endif /* Q23UTILITY_H */
constexpr auto forward_like(U &&x) noexcept -> _detail::forward_like_ret_t< T, U >
Definition q23utility.h:64