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