Skip to content

Commit

Permalink
Update libcxx/vector
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Oct 26, 2024
1 parent cf023a6 commit 39b4d9a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 13 deletions.
49 changes: 48 additions & 1 deletion test/sources/libcxx/vector/iterators.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,27 @@ TEST_CONSTEXPR_CXX20 bool tests()
C::iterator i = c.begin();
C::iterator j = c.end();
assert(std::distance(i, j) == 0);

assert(i == j);
assert(!(i != j));

assert(!(i < j));
assert((i <= j));

assert(!(i > j));
assert((i >= j));

# if TEST_STD_VER >= 20
// P1614 + LWG3352
// When the allocator does not have operator<=> then the iterator uses a
// fallback to provide operator<=>.
// Make sure to test with an allocator that does not have operator<=>.
static_assert(!std::three_way_comparable<min_allocator<int>, std::strong_ordering>);
static_assert(std::three_way_comparable<typename C::iterator, std::strong_ordering>);

std::same_as<std::strong_ordering> decltype(auto) r1 = i <=> j;
assert(r1 == std::strong_ordering::equal);
# endif
}
{
typedef int T;
Expand All @@ -93,7 +113,26 @@ TEST_CONSTEXPR_CXX20 bool tests()
C::const_iterator i = c.begin();
C::const_iterator j = c.end();
assert(std::distance(i, j) == 0);

assert(i == j);
assert(!(i != j));

assert(!(i < j));
assert((i <= j));

assert(!(i > j));
assert((i >= j));

# if TEST_STD_VER >= 20
// When the allocator does not have operator<=> then the iterator uses a
// fallback to provide operator<=>.
// Make sure to test with an allocator that does not have operator<=>.
static_assert(!std::three_way_comparable<min_allocator<int>, std::strong_ordering>);
static_assert(std::three_way_comparable<typename C::iterator, std::strong_ordering>);

std::same_as<std::strong_ordering> decltype(auto) r1 = i <=> j;
assert(r1 == std::strong_ordering::equal);
# endif
}
{
typedef int T;
Expand Down Expand Up @@ -161,8 +200,16 @@ TEST_CONSTEXPR_CXX20 bool tests()
assert ( (cii >= ii1 ));
assert (cii - ii1 == 0);
assert (ii1 - cii == 0);
# if TEST_STD_VER >= 20
// P1614 + LWG3352
std::same_as<std::strong_ordering> decltype(auto) r1 = ii1 <=> ii2;
assert(r1 == std::strong_ordering::equal);

std::same_as<std::strong_ordering> decltype(auto) r2 = cii <=> ii2;
assert(r2 == std::strong_ordering::equal);
# endif // TEST_STD_VER > 20
}
#endif
#endif // TEST_STD_VER > 11

return true;
}
Expand Down
25 changes: 14 additions & 11 deletions test/sources/libcxx/vector/types.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// };

// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS

#ifndef LIBCXX_TEST_INTCAP_ARRAY
struct A { std::vector<A> v; }; // incomplete type support
#endif
Expand All @@ -49,16 +46,22 @@ test()
// blindly pulling typedefs out of the allocator. This is why we can't call
// test<int, min_allocator<int>>() below.
static_assert((std::is_same<typename C::value_type, T>::value), "");
static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
static_assert(
(std::is_same<typename C::value_type, typename std::allocator_traits<Allocator>::value_type>::value), "");
static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
//static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
//static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
//static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
//static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
static_assert(
(std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
static_assert(
(std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value),
"");
static_assert(
(std::is_same<typename C::reference, typename std::allocator_traits<Allocator>::value_type&>::value), "");
static_assert((std::is_same<typename C::const_reference,
const typename std::allocator_traits<Allocator>::value_type&>::value),
"");
static_assert((std::is_same<typename C::pointer, typename std::allocator_traits<Allocator>::pointer>::value), "");
static_assert((std::is_same<typename C::const_pointer, typename std::allocator_traits<Allocator>::const_pointer>::value), "");
static_assert(
(std::is_same<typename C::const_pointer, typename std::allocator_traits<Allocator>::const_pointer>::value), "");

static_assert((std::is_signed<typename C::difference_type>::value), "");
static_assert((std::is_unsigned<typename C::size_type>::value), "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace adl {
struct S {};
void make_move_iterator(S*) {}
[[maybe_unused]] void make_move_iterator(S*) {}
}

TEST_CONSTEXPR_CXX20 bool tests()
Expand Down

0 comments on commit 39b4d9a

Please sign in to comment.