Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
huixie90 committed Oct 13, 2024
1 parent d04b527 commit d1409a2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 33 deletions.
14 changes: 1 addition & 13 deletions libcxx/include/__flat_map/flat_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ class flat_map {
using key_compare = __type_identity_t<_Compare>;
using reference = pair<const key_type&, mapped_type&>;
using const_reference = pair<const key_type&, const mapped_type&>;
// TODO : to support vector<bool> in the future, the following typedefs need to replace the above
// using reference = pair<ranges::range_reference_t<const _KeyContainer>,
// ranges::range_reference_t<_MappedContainer>>; using const_reference =
// pair<ranges::range_reference_t<const _KeyContainer>, ranges::range_reference_t<const _MappedContainer>>;
using size_type = size_t;
using difference_type = ptrdiff_t;
using iterator = __iterator<false>; // see [container.requirements]
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1074,14 +1070,6 @@ class flat_map {

template <class _Kp>
_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;
}
Expand Down
10 changes: 5 additions & 5 deletions libcxx/modules/std/flat_map.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
//===----------------------------------------------------------------------===//

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;
using std::sorted_unique_t;

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
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ static_assert(std::is_trivially_default_constructible_v<std::sorted_unique_t>);
static_assert(!HasImplicitDefaultCtor<std::sorted_unique_t>);

constexpr bool test() {
{
[[maybe_unused]] std::sorted_unique_t s;
}
{
[[maybe_unused]] std::same_as<const std::sorted_unique_t&> decltype(auto) s = (std::sorted_unique);
}
{
[[maybe_unused]] std::same_as<const std::sorted_unique_t> decltype(auto) copy = std::sorted_unique;
}
{ [[maybe_unused]] std::sorted_unique_t s; }
{ [[maybe_unused]] std::same_as<const std::sorted_unique_t&> decltype(auto) s = (std::sorted_unique); }
{ [[maybe_unused]] std::same_as<const std::sorted_unique_t> decltype(auto) copy = std::sorted_unique; }

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ int main(int, char**) {
using M1 = std::flat_map<int, int, C, V1, V1>;
using M2 = std::flat_map<int, int, C, V1, V2>;
using M3 = std::flat_map<int, int, C, V2, V1>;
using IL = std::initializer_list<std::pair<int, int>>;
static_assert(std::is_constructible_v<M1, const A1&>);
static_assert(!std::is_constructible_v<M1, const A2&>);
static_assert(!std::is_constructible_v<M2, const A2&>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int, char**) {
using M1 = std::flat_map<int, int, C, V1, V1>;
using M2 = std::flat_map<int, int, C, V1, V2>;
using M3 = std::flat_map<int, int, C, V2, V1>;
static_assert( std::is_constructible_v<M1, const M1&, const A1&>);
static_assert(std::is_constructible_v<M1, const M1&, const A1&>);
static_assert(!std::is_constructible_v<M1, const M1&, const A2&>);
static_assert(!std::is_constructible_v<M2, const M2&, const A2&>);
static_assert(!std::is_constructible_v<M3, const M3&, const A2&>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main(int, char**) {
using M1 = std::flat_map<int, int, C, V1, V1>;
using M2 = std::flat_map<int, int, C, V1, V2>;
using M3 = std::flat_map<int, int, C, V2, V1>;
static_assert( std::is_constructible_v<M1, M1&&, const A1&>);
static_assert(std::is_constructible_v<M1, M1&&, const A1&>);
static_assert(!std::is_constructible_v<M1, M1&&, const A2&>);
static_assert(!std::is_constructible_v<M2, M2&&, const A2&>);
static_assert(!std::is_constructible_v<M3, M3&&, const A2&>);
Expand Down Expand Up @@ -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<int, int, std::less<>, std::vector<int>, CopyOnlyVector<int>>;
M m1 = M({1,2,3},{1,2,3});
M m2 (std::move(m1), std::allocator<int>{});
assert(m2.size()==3);
M m1 = M({1, 2, 3}, {1, 2, 3});
M m2(std::move(m1), std::allocator<int>{});
assert(m2.size() == 3);
assert(m1.keys().size() == m1.values().size());
LIBCPP_ASSERT(m1.empty());
LIBCPP_ASSERT(m1.keys().size() == 0);
Expand Down

0 comments on commit d1409a2

Please sign in to comment.