Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtconcurrentfunctionwrappers.h
Go to the documentation of this file.
1
// Copyright (C) 2016 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
5
#
ifndef
QTCONCURRENT_FUNCTIONWRAPPERS_H
6
#
define
QTCONCURRENT_FUNCTIONWRAPPERS_H
7
8
#
include
<
QtConcurrent
/
qtconcurrentcompilertest
.
h
>
9
#
include
<
QtConcurrent
/
qtconcurrentreducekernel
.
h
>
10
#
include
<
QtCore
/
qfuture
.
h
>
11
12
#
include
<
tuple
>
13
14
#
if
!
defined
(
QT_NO_CONCURRENT
)
||
defined
(
Q_QDOC
)
15
16
QT_BEGIN_NAMESPACE
17
18
namespace
QtPrivate
{
19
20
struct
PushBackWrapper
21
{
22
template
<
class
C,
class
U>
23
inline
void
operator
()(C &c,
const
U &u)
const
24
{
25
return
c.push_back(u);
26
}
27
28
template
<
class
C,
class
U>
29
inline
void
operator
()(C &c, U &&u)
const
30
{
31
return
c.push_back(u);
32
}
33
};
34
35
// -- MapResultType
36
37
template
<
class
T,
class
Enable =
void
>
38
struct
Argument
39
{
40
using
Type
=
void
;
41
};
42
43
template
<
class
Sequence
>
44
struct
Argument
<
Sequence
,
typename
std
::
enable_if
<
IsIterableValue
<
Sequence
>>::
type
>
45
{
46
using
Type
=
std
::
decay_t
<
decltype
(*
std
::
declval
<
Sequence
>().
begin
())>;
47
};
48
49
template
<
class
Iterator
>
50
struct
Argument
<
Iterator
,
typename
std
::
enable_if
<
IsDereferenceableValue
<
Iterator
>>::
type
>
51
{
52
using
Type
=
std
::
decay_t
<
decltype
(*
std
::
declval
<
Iterator
>())>;
53
};
54
55
template
<
class
T
>
56
using
ArgumentType
=
typename
Argument
<
T
>::
Type
;
57
58
template
<
class
T,
class
MapFunctor>
59
struct
MapResult
60
{
61
static_assert
(
std
::
is_invocable_v
<
std
::
decay_t
<
MapFunctor
>,
ArgumentType
<
T
>>,
62
"It's not possible to invoke the function with passed argument."
);
63
using
Type
=
std
::
invoke_result_t
<
std
::
decay_t
<
MapFunctor
>,
ArgumentType
<
T
>>;
64
};
65
66
template
<
class
T,
class
MapFunctor>
67
using
MapResultType
=
typename
MapResult
<T, MapFunctor>::
Type
;
68
69
// -- ReduceResultType
70
71
template
<
class
T>
72
struct
ReduceResultType
;
73
74
template
<
class
U,
class
V>
75
struct
ReduceResultType
<
void
(*)(U&,V)>
76
{
77
using
ResultType
= U;
78
};
79
80
template
<
class
T,
class
C,
class
U>
81
struct
ReduceResultType
<T(
C
::*)(U)>
82
{
83
using
ResultType
= C;
84
};
85
86
template
<
class
U
,
class
V
>
87
struct
ReduceResultType
<
std
::
function
<
void
(
U
&,
V
)>>
88
{
89
using
ResultType
=
U
;
90
};
91
92
template
<
typename
R,
typename
...A>
93
struct
ReduceResultType
<R(*)(A...)>
94
{
95
using
ResultType
=
typename
std
::tuple_element<0,
std
::tuple<A...>>::
type
;
96
};
97
98
template
<
class
U,
class
V>
99
struct
ReduceResultType
<
void
(*)(U&,V)
noexcept
>
100
{
101
using
ResultType
= U;
102
};
103
104
template
<
class
T,
class
C,
class
U>
105
struct
ReduceResultType
<T(
C
::*)(U)
noexcept
>
106
{
107
using
ResultType
= C;
108
};
109
110
template
<
class
T
,
class
Enable
=
void
>
111
inline
constexpr
bool
hasCallOperator_v
=
false
;
112
113
template
<
class
T
>
114
inline
constexpr
bool
hasCallOperator_v
<
T
,
std
::
void_t
<
decltype
(&
T
::
operator
())>> =
true
;
115
116
template
<
class
T
,
class
Enable
=
void
>
117
inline
constexpr
bool
isIterator_v
=
false
;
118
119
template
<
class
T
>
120
inline
constexpr
bool
isIterator_v
<
T
,
std
::
void_t
<
typename
std
::
iterator_traits
<
T
>::
value_type
>> =
121
true
;
122
123
template
<
class
Callable
,
class
Sequence
>
124
using
isInvocable
=
std
::
is_invocable
<
Callable
,
typename
std
::
decay_t
<
Sequence
>::
value_type
>;
125
126
template
<
class
InitialValueType
,
class
ResultType
>
127
inline
constexpr
bool
isInitialValueCompatible_v
=
std
::
conjunction_v
<
128
std
::
is_convertible
<
InitialValueType
,
ResultType
>,
129
std
::
negation
<
std
::
is_same
<
std
::
decay_t
<
InitialValueType
>,
QtConcurrent
::
ReduceOption
>>>;
130
131
template
<
class
Callable,
class
Enable =
void
>
132
struct
ReduceResultTypeHelper
133
{
134
};
135
136
template
<
class
Callable
>
137
struct
ReduceResultTypeHelper
<
Callable
,
138
typename
std
::
enable_if_t
<
std
::
is_function_v
<
std
::
remove_pointer_t
<
std
::
decay_t
<
Callable
>>>
139
||
std
::
is_member_function_pointer_v
<
std
::
decay_t
<
Callable
>>>>
140
{
141
using
type
=
typename
QtPrivate
::
ReduceResultType
<
std
::
decay_t
<
Callable
>>::
ResultType
;
142
};
143
144
template
<
class
Callable
>
145
struct
ReduceResultTypeHelper
<
Callable
,
146
typename
std
::
enable_if_t
<!
std
::
is_function_v
<
std
::
remove_pointer_t
<
std
::
decay_t
<
Callable
>>>
147
&&
hasCallOperator_v
<
std
::
decay_t
<
Callable
>>>>
148
{
149
using
type
=
std
::
decay_t
<
typename
QtPrivate
::
ArgResolver
<
Callable
>::
First
>;
150
};
151
152
// -- MapSequenceResultType
153
154
template
<
class
InputSequence,
class
MapFunctor>
155
struct
MapSequenceResultType
156
{
157
static_assert
(
std
::
is_same_v
<
typename
InputSequence
::
value_type
,
158
QtPrivate
::
MapResultType
<
InputSequence
,
MapFunctor
>>,
159
"Couldn't deduce the output sequence type, you must specify it explicitly."
);
160
typedef
InputSequence
ResultType
;
161
};
162
163
#
ifndef
QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
164
165
template
<
template
<
typename
...>
class
InputSequence,
typename
MapFunctor,
typename
...T>
166
struct
MapSequenceResultType
<InputSequence<T...>, MapFunctor>
167
{
168
typedef
InputSequence
<
QtPrivate
::
MapResultType
<
InputSequence
<
T
...>,
MapFunctor
>>
ResultType
;
169
};
170
171
#
endif
// QT_NO_TEMPLATE_TEMPLATE_PARAMETER
172
173
}
// namespace QtPrivate.
174
175
176
QT_END_NAMESPACE
177
178
#
endif
// QT_NO_CONCURRENT
179
180
#
endif
QtPrivate
Definition
qalloc.h:29
QtPrivate::hasCallOperator_v
constexpr bool hasCallOperator_v
Definition
qtconcurrentfunctionwrappers.h:111
QtPrivate::isInitialValueCompatible_v
constexpr bool isInitialValueCompatible_v
Definition
qtconcurrentfunctionwrappers.h:127
QtPrivate::MapResultType
typename MapResult< T, MapFunctor >::Type MapResultType
Definition
qtconcurrentfunctionwrappers.h:67
QtPrivate::isIterator_v
constexpr bool isIterator_v
Definition
qtconcurrentfunctionwrappers.h:117
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QtPrivate::Argument
Definition
qtconcurrentfunctionwrappers.h:39
QtPrivate::Argument::Type
void Type
Definition
qtconcurrentfunctionwrappers.h:40
QtPrivate::MapResult
Definition
qtconcurrentfunctionwrappers.h:60
QtPrivate::MapSequenceResultType< InputSequence< T... >, MapFunctor >
Definition
qtconcurrentfunctionwrappers.h:167
QtPrivate::MapSequenceResultType< InputSequence< T... >, MapFunctor >::ResultType
InputSequence< QtPrivate::MapResultType< InputSequence< T... >, MapFunctor > > ResultType
Definition
qtconcurrentfunctionwrappers.h:168
QtPrivate::MapSequenceResultType
Definition
qtconcurrentfunctionwrappers.h:156
QtPrivate::MapSequenceResultType::ResultType
InputSequence ResultType
Definition
qtconcurrentfunctionwrappers.h:160
QtPrivate::PushBackWrapper
Definition
qtconcurrentfunctionwrappers.h:21
QtPrivate::PushBackWrapper::operator()
void operator()(C &c, U &&u) const
Definition
qtconcurrentfunctionwrappers.h:29
QtPrivate::PushBackWrapper::operator()
void operator()(C &c, const U &u) const
Definition
qtconcurrentfunctionwrappers.h:23
QtPrivate::ReduceResultTypeHelper
Definition
qtconcurrentfunctionwrappers.h:133
QtPrivate::ReduceResultType< R(*)(A...)>
Definition
qtconcurrentfunctionwrappers.h:94
QtPrivate::ReduceResultType< R(*)(A...)>::ResultType
typename std::tuple_element< 0, std::tuple< A... > >::type ResultType
Definition
qtconcurrentfunctionwrappers.h:95
QtPrivate::ReduceResultType< T(C::*)(U)>
Definition
qtconcurrentfunctionwrappers.h:82
QtPrivate::ReduceResultType< T(C::*)(U)>::ResultType
C ResultType
Definition
qtconcurrentfunctionwrappers.h:83
QtPrivate::ReduceResultType< void(*)(U &, V)>
Definition
qtconcurrentfunctionwrappers.h:76
QtPrivate::ReduceResultType< void(*)(U &, V)>::ResultType
U ResultType
Definition
qtconcurrentfunctionwrappers.h:77
QtPrivate::ReduceResultType
Definition
qtconcurrentfunctionwrappers.h:72
qtbase
src
concurrent
qtconcurrentfunctionwrappers.h
Generated on
for Qt by
1.18.0