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// Qt-Security score:significant reason:default
4#ifndef Q23UTILITY_H
5#define Q23UTILITY_H
6
7#include <QtCore/qtconfigmacros.h>
8
9#include <QtCore/q20utility.h>
10
11//
12// W A R N I N G
13// -------------
14//
15// This file is not part of the Qt API. Types and functions defined in this
16// file can reliably be replaced by their std counterparts, once available.
17// You may use these definitions in your own code, but be aware that we
18// will remove them once Qt depends on the C++ version that supports
19// them in namespace std. There will be NO deprecation warning, the
20// definitions will JUST go away.
21//
22// If you can't agree to these terms, don't use these definitions!
23//
24// We mean it.
25//
26
27QT_BEGIN_NAMESPACE
28
29namespace q23 {
30// like std::forward_like
31#ifdef __cpp_lib_forward_like
32using std::forward_like;
33#else
34
35namespace _detail {
36
37// [forward]/6.1 COPY_CONST
38template <typename A, typename B>
40 std::is_const_v<A>, const B,
41 /* else */ B
42 >;
43
44// [forward]/6.2 OVERRIDE_REF
45template <typename A, typename B>
48 /* else */ B&
49 >;
50
51// [forward]/6.3 "V"
52template <typename T, typename U>
54 T&&,
58 >
59 >;
60
61} // namespace detail
62
63// http://eel.is/c++draft/forward#lib:forward_like
64template <class T, class U>
65[[nodiscard]] constexpr auto forward_like(U &&x) noexcept
67{
68 using V = _detail::forward_like_ret_t<T, U>;
69 return static_cast<V>(x);
70}
71#endif // __cpp_lib_forward_like
72} // namespace q23
73
74QT_END_NAMESPACE
75
76#endif /* Q23UTILITY_H */
constexpr auto forward_like(U &&x) noexcept -> _detail::forward_like_ret_t< T, U >
Definition q23utility.h:65