//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // shared_ptr // template // bool operator==(const unique_ptr& x, nullptr_t) noexcept; // template // bool operator==(nullptr_t, const unique_ptr& y) noexcept; // template // bool operator!=(const unique_ptr& x, nullptr_t) noexcept; // template // bool operator!=(nullptr_t, const unique_ptr& y) noexcept; // template // bool operator<(const unique_ptr& x, nullptr_t); // template // bool operator<(nullptr_t, const unique_ptr& y); // template // bool operator<=(const unique_ptr& x, nullptr_t); // template // bool operator<=(nullptr_t, const unique_ptr& y); // template // bool operator>(const unique_ptr& x, nullptr_t); // template // bool operator>(nullptr_t, const unique_ptr& y); // template // bool operator>=(const unique_ptr& x, nullptr_t); // template // bool operator>=(nullptr_t, const unique_ptr& y); // template // requires three_­way_­comparable::pointer> // constexpr compare_three_way_result_t::pointer> // operator<=>(const unique_ptr& x, nullptr_t); // C++20 #include #include #include "test_macros.h" #include "test_comparisons.h" int main(int, char**) { AssertEqualityAreNoexcept, nullptr_t>(); AssertEqualityAreNoexcept >(); AssertComparisonsReturnBool, nullptr_t>(); AssertComparisonsReturnBool >(); #if TEST_STD_VER > 17 AssertOrderReturn, nullptr_t>(); AssertOrderReturn>(); #endif const std::unique_ptr p1(new int(1)); assert(!(p1 == nullptr)); assert(!(nullptr == p1)); assert(!(p1 < nullptr)); assert((nullptr < p1)); assert(!(p1 <= nullptr)); assert((nullptr <= p1)); assert((p1 > nullptr)); assert(!(nullptr > p1)); assert((p1 >= nullptr)); assert(!(nullptr >= p1)); #if TEST_STD_VER > 17 assert((nullptr <=> p1) == std::strong_ordering::less); assert((p1 <=> nullptr) == std::strong_ordering::greater); #endif const std::unique_ptr p2; assert((p2 == nullptr)); assert((nullptr == p2)); assert(!(p2 < nullptr)); assert(!(nullptr < p2)); assert((p2 <= nullptr)); assert((nullptr <= p2)); assert(!(p2 > nullptr)); assert(!(nullptr > p2)); assert((p2 >= nullptr)); assert((nullptr >= p2)); #if TEST_STD_VER > 17 assert((nullptr <=> p2) == std::strong_ordering::equivalent); #endif return 0; }