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
q20vector.h
Go to the documentation of this file.
1
// Copyright (C) 2023 Ahmad Samir <a.samirh78@gmail.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
5
#
ifndef
Q20VECTOR_H
6
#
define
Q20VECTOR_H
7
8
#
include
<
QtCore
/
qtconfigmacros
.
h
>
9
10
#
include
<
algorithm
>
11
#
include
<
vector
>
12
#
if
__has_include
(
<
memory_resource
>
)
13
#
include
<
memory_resource
>
14
#
endif
15
16
//
17
// W A R N I N G
18
// -------------
19
//
20
// This file is not part of the Qt API. Types and functions defined in this
21
// file can reliably be replaced by their std counterparts, once available.
22
// You may use these definitions in your own code, but be aware that we
23
// will remove them once Qt depends on the C++ version that supports
24
// them in namespace std. There will be NO deprecation warning, the
25
// definitions will JUST go away.
26
//
27
// If you can't agree to these terms, don't use these definitions!
28
//
29
// We mean it.
30
//
31
32
QT_BEGIN_NAMESPACE
33
34
namespace
q20
{
35
// like std::erase/std::erase_if for std::vector
36
#
if
defined
(
__cpp_lib_erase_if
)
&&
__cpp_lib_erase_if
>=
202002L
// the one returning size_type
37
using
std
::
erase
;
38
using
std
::
erase_if
;
39
#
else
40
41
// Make it more specialized than the compiler's, so that our implementation is preferred over
42
// the compiler's (which may be present, but return void instead of the number of erased elements).
43
44
template
<
typename
T,
typename
U>
45
constexpr
typename
std
::vector<T,
std
::allocator<T>>::
size_type
46
erase
(
std
::vector<T,
std
::allocator<T>> &c,
const
U &value)
47
{
48
const
auto
origSize = c.size();
49
auto
it =
std
::remove(c.begin(), c.end(), value);
50
c.erase(it, c.end());
51
return
origSize - c.size();
52
}
53
54
template
<
typename
T,
typename
Pred>
55
constexpr
typename
std
::vector<T,
std
::allocator<T>>::
size_type
56
erase_if
(
std
::vector<T,
std
::allocator<T>> &c, Pred pred)
57
{
58
const
auto
origSize = c.size();
59
auto
it =
std
::remove_if(c.begin(), c.end(), pred);
60
c.erase(it, c.end());
61
return
origSize - c.size();
62
}
63
64
#
ifdef
__cpp_lib_polymorphic_allocator
65
template
<
typename
T
,
typename
U
>
66
constexpr
typename
std
::
vector
<
T
,
std
::
pmr
::
polymorphic_allocator
<
T
>>::
size_type
67
erase
(
std
::
vector
<
T
,
std
::
pmr
::
polymorphic_allocator
<
T
>> &
c
,
const
U
&
value
)
68
{
69
const
auto
origSize
=
c
.
size
();
70
auto
it
=
std
::
remove
(
c
.
begin
(),
c
.
end
(),
value
);
71
c
.
erase
(
it
,
c
.
end
());
72
return
origSize
-
c
.
size
();
73
}
74
75
template
<
typename
T
,
typename
Pred
>
76
constexpr
typename
std
::
vector
<
T
,
std
::
pmr
::
polymorphic_allocator
<
T
>>::
size_type
77
erase_if
(
std
::
vector
<
T
,
std
::
pmr
::
polymorphic_allocator
<
T
>> &
c
,
Pred
pred
)
78
{
79
const
auto
origSize
=
c
.
size
();
80
auto
it
=
std
::
remove_if
(
c
.
begin
(),
c
.
end
(),
pred
);
81
c
.
erase
(
it
,
c
.
end
());
82
return
origSize
-
c
.
size
();
83
}
84
#
endif
// __cpp_lib_polymorphic_allocator
85
86
#
endif
// __cpp_lib_erase_if
87
}
// namespace q20
88
89
QT_END_NAMESPACE
90
91
#
endif
/* Q20VECTOR_H */
QMutexLocker
\inmodule QtCore
Definition
qmutex.h:347
QRhiCallback::Manager
Definition
qrhivaluemapper.cpp:16
QRhiCallback::Manager::registerCallback
void registerCallback(QRhi &rhi, const std::weak_ptr< QRhiCallback > &cb)
Definition
qrhivaluemapper.cpp:40
QRhiCallback
The QRhiCallback class implements a thread-safe wrapper around QRhi cleanup callbacks....
Definition
qrhivaluemapper_p.h:37
QRhiValueMapper
The class associates values of the specified type with different QRhi. One instance of QRhiValueMappe...
Definition
qrhivaluemapper_p.h:70
QRhiValueMapper::operator=
QRhiValueMapper & operator=(QRhiValueMapper &&) noexcept=default
QRhiValueMapper::getOrCreate
Value & getOrCreate(QRhi &rhi, Functor &&factory)
Definition
qrhivaluemapper_p.h:119
QRhiValueMapper::QRhiValueMapper
QRhiValueMapper(QRhiValueMapper &&) noexcept=default
QRhiValueMapper::findRhi
QRhi * findRhi(Predicate &&p) const
Definition
qrhivaluemapper_p.h:145
QRhiValueMapper::clear
void clear()
Definition
qrhivaluemapper_p.h:136
QRhiValueMapper::tryMap
std::pair< Value *, bool > tryMap(QRhi &rhi, V &&value)
Definition
qrhivaluemapper_p.h:99
QRhiValueMapper::~QRhiValueMapper
~QRhiValueMapper()
Definition
qrhivaluemapper_p.h:86
QRhiValueMapper::QRhiValueMapper
QRhiValueMapper()
Definition
qrhivaluemapper_p.h:96
QRhiValueMapper::get
Value * get(QRhi *rhi) const
Definition
qrhivaluemapper_p.h:111
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
q20
Definition
qnumeric.cpp:467
q20::erase
constexpr std::vector< T, std::allocator< T > >::size_type erase(std::vector< T, std::allocator< T > > &c, const U &value)
Definition
q20vector.h:46
q20::erase_if
constexpr std::vector< T, std::allocator< T > >::size_type erase_if(std::vector< T, std::allocator< T > > &c, Pred pred)
Definition
q20vector.h:56
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
__has_include
#define __has_include(x)
Definition
qcompilerdetection.h:459
QBasicMutex
QMutex QBasicMutex
Definition
qmutex.h:361
Q_GLOBAL_STATIC
Q_GLOBAL_STATIC(const QTzTimeZoneHash, tzZones, loadTzTimeZones())
qtbase
src
corelib
global
q20vector.h
Generated on
for Qt by
1.18.0