Warning, file /include/QtCore/q20vector.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef Q20VECTOR_H
0006 #define Q20VECTOR_H
0007
0008 #include <QtCore/qtconfigmacros.h>
0009
0010 #include <algorithm>
0011 #include <vector>
0012 #if __has_include(<memory_resource>)
0013 # include <memory_resource>
0014 #endif
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 QT_BEGIN_NAMESPACE
0033
0034 namespace q20 {
0035
0036 #if defined(__cpp_lib_erase_if) && __cpp_lib_erase_if >= 202002L
0037 using std::erase;
0038 using std::erase_if;
0039 #else
0040
0041
0042
0043
0044 template <typename T, typename U>
0045 constexpr typename std::vector<T, std::allocator<T>>::size_type
0046 erase(std::vector<T, std::allocator<T>> &c, const U &value)
0047 {
0048 const auto origSize = c.size();
0049 auto it = std::remove(c.begin(), c.end(), value);
0050 c.erase(it, c.end());
0051 return origSize - c.size();
0052 }
0053
0054 template <typename T, typename Pred>
0055 constexpr typename std::vector<T, std::allocator<T>>::size_type
0056 erase_if(std::vector<T, std::allocator<T>> &c, Pred pred)
0057 {
0058 const auto origSize = c.size();
0059 auto it = std::remove_if(c.begin(), c.end(), pred);
0060 c.erase(it, c.end());
0061 return origSize - c.size();
0062 }
0063
0064 #ifdef __cpp_lib_polymorphic_allocator
0065 template <typename T, typename U>
0066 constexpr typename std::vector<T, std::pmr::polymorphic_allocator<T>>::size_type
0067 erase(std::vector<T, std::pmr::polymorphic_allocator<T>> &c, const U &value)
0068 {
0069 const auto origSize = c.size();
0070 auto it = std::remove(c.begin(), c.end(), value);
0071 c.erase(it, c.end());
0072 return origSize - c.size();
0073 }
0074
0075 template <typename T, typename Pred>
0076 constexpr typename std::vector<T, std::pmr::polymorphic_allocator<T>>::size_type
0077 erase_if(std::vector<T, std::pmr::polymorphic_allocator<T>> &c, Pred pred)
0078 {
0079 const auto origSize = c.size();
0080 auto it = std::remove_if(c.begin(), c.end(), pred);
0081 c.erase(it, c.end());
0082 return origSize - c.size();
0083 }
0084 #endif
0085
0086 #endif
0087 }
0088
0089 QT_END_NAMESPACE
0090
0091 #endif