Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ void test() {
using Key = typename KeyContainer::value_type;
using Value = typename ValueContainer::value_type;
using M = std::flat_map<Key, Value, std::less<Key>, KeyContainer, ValueContainer>;
using KI = typename KeyContainer::iterator;
using I = M::iterator;
using CI = M::const_iterator;
using RI = M::reverse_iterator;
Expand Down Expand Up @@ -115,34 +114,32 @@ void test() {
assert(cri2 >= cri2);
assert(!(cri1 >= cri2));

if constexpr (std::three_way_comparable<KI>) {
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}

int main(int, char**) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ void test() {
using Key = typename KeyContainer::value_type;
using Value = typename ValueContainer::value_type;
using M = std::flat_multimap<Key, Value, std::less<Key>, KeyContainer, ValueContainer>;
using KI = typename KeyContainer::iterator;
using I = M::iterator;
using CI = M::const_iterator;
using RI = M::reverse_iterator;
Expand Down Expand Up @@ -115,34 +114,32 @@ void test() {
assert(cri2 >= cri2);
assert(!(cri1 >= cri2));

if constexpr (std::three_way_comparable<KI>) {
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}

int main(int, char**) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ template <class KeyContainer>
void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
using KI = typename KeyContainer::iterator;
using I = M::iterator;
using CI = M::const_iterator;
using RI = M::reverse_iterator;
Expand Down Expand Up @@ -114,34 +113,32 @@ void test_one() {
assert(cri2 >= cri2);
assert(!(cri1 >= cri2));

if constexpr (std::three_way_comparable<KI>) {
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}

void test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ template <class KeyContainer>
void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using KI = typename KeyContainer::iterator;
using I = M::iterator;
using CI = M::const_iterator;
using RI = M::reverse_iterator;
Expand Down Expand Up @@ -114,34 +113,32 @@ void test_one() {
assert(cri2 >= cri2);
assert(!(cri1 >= cri2));

if constexpr (std::three_way_comparable<KI>) {
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
static_assert(std::three_way_comparable<CI>);
static_assert(std::three_way_comparable<RI>);
static_assert(std::three_way_comparable<CRI>);
static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);

assert(i1 <=> i1 == std::strong_ordering::equivalent);
assert(i1 <=> i2 == std::strong_ordering::less);
assert(i2 <=> i1 == std::strong_ordering::greater);

assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
assert(ci1 <=> ci2 == std::strong_ordering::less);
assert(ci2 <=> ci1 == std::strong_ordering::greater);

assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
assert(ri1 <=> ri2 == std::strong_ordering::less);
assert(ri2 <=> ri1 == std::strong_ordering::greater);

assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
assert(cri1 <=> cri2 == std::strong_ordering::less);
assert(cri2 <=> cri1 == std::strong_ordering::greater);
}

void test() {
Expand Down
4 changes: 3 additions & 1 deletion libcxx/test/support/MinSequenceContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#include "test_iterators.h"

template <class T, class Iterator = random_access_iterator<T*>, class ConstIterator = random_access_iterator<const T*>>
template <class T,
class Iterator = three_way_random_access_iterator<T*>,
class ConstIterator = three_way_random_access_iterator<const T*>>
struct MinSequenceContainer {
using value_type = T;
using difference_type = int;
Expand Down
Loading