@@ -577,6 +577,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
577577# include < __algorithm/equal.h>
578578# include < __algorithm/lexicographical_compare.h>
579579# include < __algorithm/lexicographical_compare_three_way.h>
580+ # include < __algorithm/specialized_algorithms.h>
580581# include < __assert>
581582# include < __config>
582583# include < __functional/binary_function.h>
@@ -1375,6 +1376,8 @@ private:
13751376# ifdef _LIBCPP_CXX03_LANG
13761377 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key (const key_type& __k);
13771378# endif
1379+
1380+ friend struct __specialized_algorithm <_Algorithm::__for_each, map>;
13781381};
13791382
13801383# if _LIBCPP_STD_VER >= 17
@@ -1427,6 +1430,23 @@ map(initializer_list<pair<_Key, _Tp>>, _Allocator)
14271430 -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
14281431# endif
14291432
1433+ # if _LIBCPP_STD_VER >= 14
1434+ template <class _Key , class _Tp , class _Compare , class _Allocator >
1435+ struct __specialized_algorithm <_Algorithm::__for_each, map<_Key, _Tp, _Compare, _Allocator>> {
1436+ using __map _LIBCPP_NODEBUG = map<_Key, _Tp, _Compare, _Allocator>;
1437+
1438+ static const bool __has_algorithm = true ;
1439+
1440+ // set's begin() and end() are identical with and without const qualifiaction
1441+ template <class _Map , class _Func >
1442+ _LIBCPP_HIDE_FROM_ABI static auto operator ()(_Map&& __map, _Func __func) {
1443+ auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, typename __map::__base>()(
1444+ __map.__tree_ , std::move (__func));
1445+ return std::make_pair (__map.end (), std::move (__func2));
1446+ }
1447+ };
1448+ # endif
1449+
14301450# ifndef _LIBCPP_CXX03_LANG
14311451template <class _Key , class _Tp , class _Compare , class _Allocator >
14321452map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
@@ -1940,6 +1960,8 @@ private:
19401960
19411961 typedef __map_node_destructor<__node_allocator> _Dp;
19421962 typedef unique_ptr<__node, _Dp> __node_holder;
1963+
1964+ friend struct __specialized_algorithm <_Algorithm::__for_each, multimap>;
19431965};
19441966
19451967# if _LIBCPP_STD_VER >= 17
@@ -1992,6 +2014,23 @@ multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
19922014 -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
19932015# endif
19942016
2017+ # if _LIBCPP_STD_VER >= 14
2018+ template <class _Key , class _Tp , class _Compare , class _Allocator >
2019+ struct __specialized_algorithm <_Algorithm::__for_each, multimap<_Key, _Tp, _Compare, _Allocator>> {
2020+ using __map _LIBCPP_NODEBUG = multimap<_Key, _Tp, _Compare, _Allocator>;
2021+
2022+ static const bool __has_algorithm = true ;
2023+
2024+ // set's begin() and end() are identical with and without const qualifiaction
2025+ template <class _Map , class _Func >
2026+ _LIBCPP_HIDE_FROM_ABI static auto operator ()(_Map&& __map, _Func __func) {
2027+ auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, typename __map::__base>()(
2028+ __map.__tree_ , std::move (__func));
2029+ return std::make_pair (__map.end (), std::move (__func2));
2030+ }
2031+ };
2032+ # endif
2033+
19952034# ifndef _LIBCPP_CXX03_LANG
19962035template <class _Key , class _Tp , class _Compare , class _Allocator >
19972036multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
0 commit comments