diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h index 42ee8d9d318f56..70d01b2692b35e 100644 --- a/libcxx/include/__flat_map/flat_map.h +++ b/libcxx/include/__flat_map/flat_map.h @@ -90,10 +90,6 @@ class flat_map { using key_compare = __type_identity_t<_Compare>; using reference = pair; using const_reference = pair; - // TODO : to support vector in the future, the following typedefs need to replace the above - // using reference = pair, - // ranges::range_reference_t<_MappedContainer>>; using const_reference = - // pair, ranges::range_reference_t>; using size_type = size_t; using difference_type = ptrdiff_t; using iterator = __iterator; // see [container.requirements] @@ -985,7 +981,7 @@ class flat_map { ranges::stable_sort(__zv.begin() + __append_start_offset, __end, __compare_key); } else { _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( - __is_sorted_and_unique(__containers_.keys | views::drop(__append_start_offset)), + __is_sorted_and_unique(__containers_.keys | ranges::views::drop(__append_start_offset)), "Either the key container is not sorted or it contains duplicates"); } ranges::inplace_merge(__zv.begin(), __zv.begin() + __append_start_offset, __end, __compare_key); @@ -1074,14 +1070,6 @@ class flat_map { template _LIBCPP_HIDE_FROM_ABI bool __is_hint_correct(const_iterator __hint, _Kp&& __key) { - // todo - // note that we have very fragile std::prev in our library - // for non LegacyBidirectional iterator, std::prev(it) is well formed and a no-op - // here we cannot use std::prev because our iterator is not legacy bidirectional - // since its reference type is not a reference - // note that user can also attempt to use std::prev on the flat_map::iterator - // and it would result in a no-op. - // we should probably ban std::prev(LegacyInputIterator) if (__hint != cbegin() && !__compare_((__hint - 1)->first, __key)) { return false; } diff --git a/libcxx/modules/std/flat_map.inc b/libcxx/modules/std/flat_map.inc index 83cd20ad618946..1ab7148acf8fc5 100644 --- a/libcxx/modules/std/flat_map.inc +++ b/libcxx/modules/std/flat_map.inc @@ -8,8 +8,7 @@ //===----------------------------------------------------------------------===// export namespace std { -#if 0 - // [flat.map], class template flat_­map + // [flat.map], class template flat_map using std::flat_map; using std::sorted_unique; @@ -17,15 +16,16 @@ export namespace std { using std::uses_allocator; - // [flat.map.erasure], erasure for flat_­map + // [flat.map.erasure], erasure for flat_map using std::erase_if; - // [flat.multimap], class template flat_­multimap +#if 0 + // [flat.multimap], class template flat_multimap using std::flat_multimap; using std::sorted_equivalent; using std::sorted_equivalent_t; - // [flat.multimap.erasure], erasure for flat_­multimap + // [flat.multimap.erasure], erasure for flat_multimap #endif } // namespace std diff --git a/libcxx/test/std/containers/container.adaptors/flat.map.syn/sorted_unique.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map.syn/sorted_unique.pass.cpp index 59338e2da5aedc..f8bbb070b2f91d 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map.syn/sorted_unique.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map.syn/sorted_unique.pass.cpp @@ -29,15 +29,9 @@ static_assert(std::is_trivially_default_constructible_v); static_assert(!HasImplicitDefaultCtor); constexpr bool test() { - { - [[maybe_unused]] std::sorted_unique_t s; - } - { - [[maybe_unused]] std::same_as decltype(auto) s = (std::sorted_unique); - } - { - [[maybe_unused]] std::same_as decltype(auto) copy = std::sorted_unique; - } + { [[maybe_unused]] std::sorted_unique_t s; } + { [[maybe_unused]] std::same_as decltype(auto) s = (std::sorted_unique); } + { [[maybe_unused]] std::same_as decltype(auto) copy = std::sorted_unique; } return true; } diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp index 53ccb388084c22..8dee25a24760ae 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp @@ -37,7 +37,6 @@ int main(int, char**) { using M1 = std::flat_map; using M2 = std::flat_map; using M3 = std::flat_map; - using IL = std::initializer_list>; static_assert(std::is_constructible_v); static_assert(!std::is_constructible_v); static_assert(!std::is_constructible_v); diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp index 99da4b33a45c98..2b01243622da9a 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp @@ -37,7 +37,7 @@ int main(int, char**) { using M1 = std::flat_map; using M2 = std::flat_map; using M3 = std::flat_map; - static_assert( std::is_constructible_v); + static_assert(std::is_constructible_v); static_assert(!std::is_constructible_v); static_assert(!std::is_constructible_v); static_assert(!std::is_constructible_v); diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp index b998f7c876e107..45627850822f9a 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp @@ -39,7 +39,7 @@ int main(int, char**) { using M1 = std::flat_map; using M2 = std::flat_map; using M3 = std::flat_map; - static_assert( std::is_constructible_v); + static_assert(std::is_constructible_v); static_assert(!std::is_constructible_v); static_assert(!std::is_constructible_v); static_assert(!std::is_constructible_v); @@ -100,9 +100,9 @@ int main(int, char**) { { // moved-from object maintains invariant if one of underlying container does not clear after move using M = std::flat_map, std::vector, CopyOnlyVector>; - M m1 = M({1,2,3},{1,2,3}); - M m2 (std::move(m1), std::allocator{}); - assert(m2.size()==3); + M m1 = M({1, 2, 3}, {1, 2, 3}); + M m2(std::move(m1), std::allocator{}); + assert(m2.size() == 3); assert(m1.keys().size() == m1.values().size()); LIBCPP_ASSERT(m1.empty()); LIBCPP_ASSERT(m1.keys().size() == 0);