> );
std::vector c{ {1}, {2}, {-3} };
static_assert( std::three_way_comparable
);
static_assert( std::same_as c), std::partial_ordering> );
VERIFY( (c <=> c) == std::partial_ordering::unordered );
return true;
}
constexpr bool
test04()
{
struct L
{
int value = 0;
constexpr bool operator<(L rhs) const noexcept { return value < rhs.value; }
};
static_assert( std::totally_ordered> );
std::vector c{ {1}, {2}, {3} }, d{ {1}, {2}, {3}, {4} };
static_assert( std::same_as c), std::weak_ordering> );
VERIFY( std::is_lt(c <=> d) );
return true;
}
constexpr bool
test05()
{
// vector iterators are random access, so should support <=>
std::vector c{ 1, 2, 3 };
VERIFY( c.begin() == c.cbegin() );
VERIFY( std::is_eq(c.begin() <=> c.cbegin()) );
VERIFY( c.begin() < c.end() );
VERIFY( std::is_lt(c.begin() <=> c.end()) );
VERIFY( c.begin() < c.cend() );
VERIFY( std::is_lt(c.begin() <=> c.cend()) );
VERIFY( c.crbegin() == c.rbegin() );
VERIFY( std::is_eq(c.crbegin() <=> c.rbegin()) );
VERIFY( c.rend() > c.rbegin() );
VERIFY( std::is_gt(c.rend() <=> c.rbegin()) );
static_assert( std::same_as c.begin()),
std::strong_ordering> );
return true;
}
static_assert( test01() );
static_assert( test02() );
static_assert( test03() );
static_assert( test04() );
static_assert( test05() );