File indexing completed on 2026-09-19 09:31:59
0001
0002
0003
0004
0005
0006 #ifndef Q20MAP_H
0007 #define Q20MAP_H
0008
0009 #include <QtCore/qtconfigmacros.h>
0010
0011 #include <map>
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_if;
0038 #else
0039
0040
0041
0042
0043 #define MAKE_OVERLOAD(map, allocator) \
0044 template <typename Key, typename T, typename Compare, typename Pred> \
0045 constexpr typename std::map<Key, T, Compare, std::allocator<std::pair<const Key, T>>>::size_type \
0046 erase_if(std::map<Key, T, Compare, std::allocator<std::pair<const Key, T>>> &c, Pred p) \
0047 { \
0048 const auto origSize = c.size(); \
0049 for (auto it = c.begin(), end = c.end(); it != end; ) { \
0050 if (p(*it)) \
0051 it = c.erase(it); \
0052 else \
0053 ++it; \
0054 } \
0055 return origSize - c.size(); \
0056 } \
0057
0058
0059 MAKE_OVERLOAD(map, allocator)
0060 MAKE_OVERLOAD(multimap, allocator)
0061 #ifdef __cpp_lib_polymorphic_allocator
0062 MAKE_OVERLOAD(map, pmr::polymorphic_allocator)
0063 MAKE_OVERLOAD(multimap, pmr::polymorphic_allocator)
0064 #endif
0065
0066 #undef MAKE_OVERLOAD
0067
0068 #endif
0069 }
0070
0071 QT_END_NAMESPACE
0072
0073 #endif