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
qttypetraits.h
Go to the documentation of this file.
1
// Copyright (C) 2022 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
4
#ifndef QTTYPETRAITS_H
5
#define QTTYPETRAITS_H
6
7
#include <QtCore/qtconfigmacros.h>
8
#include <QtCore/qtdeprecationmarkers.h>
9
10
#include <type_traits>
11
#include <utility>
12
13
#if 0
14
#pragma qt_class(QtTypeTraits)
15
#pragma qt_sync_stop_processing
16
#endif
17
18
QT_BEGIN_NAMESPACE
19
20
// like std::to_underlying
21
template
<
typename
Enum>
22
constexpr
std::underlying_type_t<Enum>
qToUnderlying
(
Enum
e)
noexcept
23
{
24
return
static_cast<
std::underlying_type_t<Enum>
>
(e);
25
}
26
27
#ifndef QT_NO_QASCONST
28
#if QT_DEPRECATED_SINCE(6, 6)
29
30
// this adds const to non-const objects (like std::as_const)
31
template
<
typename
T>
32
QT_DEPRECATED_VERSION_X_6_6
(
"Use std::as_const() instead."
)
33
constexpr typename
std
::add_const<T>::
type
&qAsConst(T &
t
) noexcept {
return
t
; }
34
// prevent rvalue arguments:
35
template
<
typename
T>
36
void
qAsConst(
const
T &&) =
delete
;
37
38
#endif
// QT_DEPRECATED_SINCE(6, 6)
39
#endif
// QT_NO_QASCONST
40
41
#ifndef QT_NO_QEXCHANGE
42
43
// like std::exchange
44
template
<
typename
T,
typename
U = T>
45
constexpr
T
qExchange
(T &
t
, U &&newValue)
46
noexcept
(std::conjunction_v<std::is_nothrow_move_constructible<T>,
47
std::is_nothrow_assignable<T &, U>>)
48
{
49
T old = std::move(
t
);
50
t
= std::forward<U>(newValue);
51
return
old;
52
}
53
54
#endif
// QT_NO_QEXCHANGE
55
56
namespace
QtPrivate
{
57
// helper to be used to trigger a "dependent static_assert(false)"
58
// (for instance, in a final `else` branch of a `if constexpr`.)
59
template
<
typename
T>
struct
type_dependent_false
: std::false_type {};
60
template
<auto T>
struct
value_dependent_false
: std::false_type {};
61
}
62
63
QT_END_NAMESPACE
64
65
#endif
// QTTYPETRAITS_H
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1590
QtPrivate
\macro QT_NO_KEYWORDS >
Definition
qtconcurrentcompilertest.h:13
std
Definition
qfloat16.h:502
type
GLenum type
Definition
qopengles2ext.h:150
t
GLdouble GLdouble t
Definition
qopenglext.h:243
QT_DEPRECATED_VERSION_X_6_6
#define QT_DEPRECATED_VERSION_X_6_6(text)
Definition
qtdeprecationmarkers.h:175
qToUnderlying
QT_BEGIN_NAMESPACE constexpr std::underlying_type_t< Enum > qToUnderlying(Enum e) noexcept
Definition
qttypetraits.h:22
qExchange
constexpr T qExchange(T &t, U &&newValue) noexcept(std::conjunction_v< std::is_nothrow_move_constructible< T >, std::is_nothrow_assignable< T &, U > >)
Definition
qttypetraits.h:45
Enum
Definition
qmetatypesjsonprocessor_p.h:126
QtPrivate::type_dependent_false
Definition
qttypetraits.h:59
QtPrivate::value_dependent_false
Definition
qttypetraits.h:60
qtbase
src
corelib
global
qttypetraits.h
Generated by
1.10.0