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
q20type_traits.h
Go to the documentation of this file.
1
// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
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
Q20TYPE_TRAITS_H
5
#
define
Q20TYPE_TRAITS_H
6
7
#
include
<
QtCore
/
qcompilerdetection
.
h
>
8
#
include
<
QtCore
/
qsystemdetection
.
h
>
9
#
include
<
QtCore
/
qtconfigmacros
.
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
27
#
include
<
type_traits
>
28
29
QT_BEGIN_NAMESPACE
30
31
namespace
q20
{
32
// like std::is_(un)bounded_array
33
#
ifdef
__cpp_lib_bounded_array_traits
34
using
std
::
is_bounded_array
;
35
using
std
::
is_bounded_array_v
;
36
using
std
::
is_unbounded_array
;
37
using
std
::
is_unbounded_array_v
;
38
#
else
39
template
<
typename
T>
struct
is_bounded_array
:
std
::
false_type
{};
40
template
<
typename
T,
std
::size_t N>
struct
is_bounded_array
<T[N]> :
std
::
true_type
{};
41
template
<
typename
T>
struct
is_unbounded_array
:
std
::
false_type
{};
42
template
<
typename
T>
struct
is_unbounded_array
<T[]> :
std
::
true_type
{};
43
template
<
typename
T
>
constexpr
inline
bool
is_bounded_array_v
=
q20
::
is_bounded_array
<
T
>::
value
;
44
template
<
typename
T
>
constexpr
inline
bool
is_unbounded_array_v
=
q20
::
is_unbounded_array
<
T
>::
value
;
45
#
endif
46
}
47
48
namespace
q20
{
49
// like std::is_constant_evaluated
50
#
ifdef
__cpp_lib_is_constant_evaluated
51
using
std
::
is_constant_evaluated
;
52
#
define
QT_SUPPORTS_IS_CONSTANT_EVALUATED
53
#
else
54
constexpr
bool
is_constant_evaluated
()
noexcept
55
{
56
#
ifdef
Q_OS_INTEGRITY
57
// Integrity complains "calling __has_builtin() from a constant expression".
58
// Avoid the __has_builtin check until we know what's going on.
59
return
false
;
60
#
elif
__has_builtin
(
__builtin_is_constant_evaluated
)
||
61
(
defined
(
Q_CC_MSVC_ONLY
)
/* >= 1925, but we require 1927 in qglobal.h */
)
62
#
define
QT_SUPPORTS_IS_CONSTANT_EVALUATED
63
return
__builtin_is_constant_evaluated();
64
#
else
65
return
false
;
66
#
endif
67
}
68
#
endif
// __cpp_lib_is_constant_evaluated
69
}
70
71
namespace
q20
{
72
// like std::remove_cvref(_t)
73
#
ifdef
__cpp_lib_remove_cvref
74
using
std
::
remove_cvref
;
75
using
std
::
remove_cvref_t
;
76
#
else
77
template
<
typename
T
>
78
using
remove_cvref
=
std
::
remove_cv
<
std
::
remove_reference_t
<
T
>>;
79
template
<
typename
T
>
80
using
remove_cvref_t
=
std
::
remove_cv_t
<
std
::
remove_reference_t
<
T
>>;
81
#
endif
// __cpp_lib_remove_cvref
82
}
83
84
namespace
q20
{
85
// like std::type_identity(_t)
86
#
ifdef
__cpp_lib_type_identity
87
using
std
::
type_identity
;
88
using
std
::
type_identity_t
;
89
#
else
90
template
<
typename
T>
91
struct
type_identity
{
using
type
= T; };
92
template
<
typename
T>
93
using
type_identity_t
=
typename
type_identity
<T>::
type
;
94
#
endif
// __cpp_lib_type_identity
95
}
96
97
QT_END_NAMESPACE
98
99
#
endif
/* Q20TYPE_TRAITS_H */
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
q20
Definition
qnumeric.cpp:464
q20::is_constant_evaluated
constexpr bool is_constant_evaluated() noexcept
Definition
q20type_traits.h:54
q20::is_bounded_array_v
constexpr bool is_bounded_array_v
Definition
q20type_traits.h:43
q20::type_identity_t
typename type_identity< T >::type type_identity_t
Definition
q20type_traits.h:93
q20::is_unbounded_array_v
constexpr bool is_unbounded_array_v
Definition
q20type_traits.h:44
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
__has_builtin
#define __has_builtin(x)
Definition
qcompilerdetection.h:444
q20::is_bounded_array< T[N]>
Definition
q20type_traits.h:40
q20::is_bounded_array
Definition
q20type_traits.h:39
q20::is_unbounded_array< T[]>
Definition
q20type_traits.h:42
q20::is_unbounded_array
Definition
q20type_traits.h:41
q20::type_identity
Definition
q20type_traits.h:91
q20::type_identity::type
T type
Definition
q20type_traits.h:91
qtbase
src
corelib
global
q20type_traits.h
Generated on
for Qt by
1.16.1