Skip to content

Commit 8d157bf

Browse files
committed
address more comments
1 parent b381bd7 commit 8d157bf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

libcxx/include/__flat_map/flat_map.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ class flat_map {
142142
friend flat_map;
143143

144144
public:
145-
using iterator_concept = random_access_iterator_tag;
146-
using iterator_category = input_iterator_tag;
145+
using iterator_concept = random_access_iterator_tag;
146+
// `flat_map::iterator` only satisfy "Cpp17InputIterator" named requirements, because
147+
// its `reference` is not a reference type.
148+
// However, to avoid surprising runtime behaviour when it is used with the
149+
// Cpp17 algorithms or operations, iterator_category is set to random_access_iterator_tag.
150+
using iterator_category = random_access_iterator_tag;
147151
using value_type = flat_map::value_type;
148152
using difference_type = flat_map::difference_type;
149153

@@ -482,7 +486,7 @@ class flat_map {
482486
_LIBCPP_HIDE_FROM_ABI flat_map& operator=(flat_map&& __other) noexcept(
483487
is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> &&
484488
is_nothrow_move_assignable_v<_Compare>) {
485-
auto __clear_other_guard = std::__make_scoped_guard([&]() noexcept { __other.clear() /* noexcept */; });
489+
auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; });
486490
auto __clear_self_guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
487491
__containers_ = std::move(__other.__containers_);
488492
__compare_ = std::move(__other.__compare_);
@@ -660,7 +664,7 @@ class flat_map {
660664
}
661665

662666
_LIBCPP_HIDE_FROM_ABI containers extract() && {
663-
auto __guard = std::__make_scoped_guard([&]() noexcept { clear() /* noexcept */; });
667+
auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
664668
auto __ret = std::move(__containers_);
665669
return __ret;
666670
}

libcxx/include/__utility/exception_guard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __exception_guard<_Rollback> __make_exce
138138
}
139139

140140
template <class _Rollback>
141-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __exception_guard_exceptions<_Rollback> __make_scoped_guard(_Rollback __rollback) {
141+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __exception_guard_exceptions<_Rollback>
142+
__make_scope_guard(_Rollback __rollback) {
142143
return __exception_guard_exceptions<_Rollback>(std::move(__rollback));
143144
}
144145

0 commit comments

Comments
 (0)