Skip to content

Commit b57f250

Browse files
committed
review
1 parent 932a123 commit b57f250

File tree

6 files changed

+12
-205
lines changed

6 files changed

+12
-205
lines changed

libcxx/include/__flat_map/flat_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ class flat_map {
10401040
friend __flat_map_utils;
10411041

10421042
containers __containers_;
1043-
[[no_unique_address]] key_compare __compare_;
1043+
_LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
10441044

10451045
struct __key_equiv {
10461046
_LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}

libcxx/include/__flat_map/flat_multimap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <__algorithm/ranges_is_sorted.h>
1919
#include <__algorithm/ranges_lower_bound.h>
2020
#include <__algorithm/ranges_partition_point.h>
21-
#include <__algorithm/ranges_stable_sort.h>
21+
#include <__algorithm/ranges_sort.h>
2222
#include <__algorithm/ranges_unique.h>
2323
#include <__algorithm/ranges_upper_bound.h>
2424
#include <__algorithm/remove_if.h>
@@ -758,7 +758,7 @@ class flat_multimap {
758758

759759
_LIBCPP_HIDE_FROM_ABI void __sort() {
760760
auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
761-
ranges::stable_sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); });
761+
ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); });
762762
}
763763

764764
template <class _Self, class _KeyIter>
@@ -780,7 +780,7 @@ class flat_multimap {
780780
return __compare_(std::get<0>(__p1), std::get<0>(__p2));
781781
};
782782
if constexpr (!_WasSorted) {
783-
ranges::stable_sort(__zv.begin() + __append_start_offset, __end, __compare_key);
783+
ranges::sort(__zv.begin() + __append_start_offset, __end, __compare_key);
784784
} else {
785785
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
786786
__is_sorted(__containers_.keys | ranges::views::drop(__append_start_offset)),
@@ -850,7 +850,7 @@ class flat_multimap {
850850
friend __flat_map_utils;
851851

852852
containers __containers_;
853-
[[no_unique_address]] key_compare __compare_;
853+
_LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
854854

855855
struct __key_equiv {
856856
_LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}

libcxx/include/__flat_map/utils.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ _LIBCPP_PUSH_MACROS
2727

2828
_LIBCPP_BEGIN_NAMESPACE_STD
2929

30-
// It is easier to be-friend to have a struct with static functions
30+
// These utilities are defined in a class instead of a namespace so that this class can be befriended more easily.
3131
struct __flat_map_utils {
32+
// Emplace a {key: value} into a flat_{multi}map, at the exact position that
33+
// __it_key and __it_mapped point to, assuming that the key is not already present in the map.
34+
// When an exception is thrown during the emplacement, the function will try its best to
35+
// roll back the changes it made to the map. If it cannot roll back the changes, it will
36+
// clear the map.
3237
template <class _Map, class _IterK, class _IterM, class _KeyArg, class... _MArgs>
3338
_LIBCPP_HIDE_FROM_ABI static typename _Map::iterator __emplace_exact_pos(
3439
_Map& __map, _IterK&& __it_key, _IterM&& __it_mapped, _KeyArg&& __key, _MArgs&&... __mapped_args) {
@@ -74,6 +79,7 @@ struct __flat_map_utils {
7479
return typename _Map::iterator(std::move(__key_it), std::move(__mapped_it));
7580
}
7681

82+
// TODO: We could optimize this, see
7783
// https://github.com/llvm/llvm-project/issues/108624
7884
template <class _Map, class _InputIterator, class _Sentinel>
7985
_LIBCPP_HIDE_FROM_ABI static typename _Map::size_type

libcxx/test/libcxx/containers/container.adaptors/flat.multimap/container_stability.pass.cpp

Lines changed: 0 additions & 68 deletions
This file was deleted.

libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/iter_iter_stability.pass.cpp

Lines changed: 0 additions & 66 deletions
This file was deleted.

libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.modifiers/insert_range_stability.pass.cpp

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)