Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 <utility>
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
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>
38using copy_const_t = std::conditional_t<
39 std::is_const_v<A>, const B,
40 /* else */ B
41 >;
42
43// [forward]/6.2 OVERRIDE_REF
44template <typename A, typename B>
45using override_ref_t = std::conditional_t<
46 std::is_rvalue_reference_v<A>, std::remove_reference_t<B>&&,
47 /* else */ B&
48 >;
49
50// [forward]/6.3 "V"
51template <typename T, typename U>
53 T&&,
55 std::remove_reference_t<T>,
56 std::remove_reference_t<U>
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{
68 return static_cast<V>(x);
69}
70#endif // __cpp_lib_forward_like
71} // namespace q23
72
74
75#endif /* Q23UTILITY_H */
Combined button and popup list for selecting options.
override_ref_t< T &&, copy_const_t< std::remove_reference_t< T >, std::remove_reference_t< U > > > forward_like_ret_t
Definition q23utility.h:52
std::conditional_t< std::is_const_v< A >, const B, B > copy_const_t
Definition q23utility.h:38
std::conditional_t< std::is_rvalue_reference_v< A >, std::remove_reference_t< B > &&, B & > override_ref_t
Definition q23utility.h:45
constexpr auto forward_like(U &&x) noexcept -> _detail::forward_like_ret_t< T, U >
Definition q23utility.h:64
GLint GLint GLint GLint GLint x
[0]