//===----------------------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // unique_ptr // template // bool // operator< (const unique_ptr& x, const unique_ptr& y); // template // bool // operator> (const unique_ptr& x, const unique_ptr& y); // template // bool // operator<=(const unique_ptr& x, const unique_ptr& y); // template // bool // operator>=(const unique_ptr& x, const unique_ptr& y); #include #include #include "test_macros.h" #include "deleter_types.h" struct A { static int count; A() {++count;} A(const A&) {++count;} virtual ~A() {--count;} }; int A::count = 0; struct B : public A { static int count; B() {++count;} B(const B& other) : A(other) {++count;} virtual ~B() {--count;} }; int B::count = 0; int main(int, char**) { { const std::unique_ptr > p1(new A); const std::unique_ptr > p2(new A); assert((p1 < p2) == !(p1 > p2)); assert((p1 < p2) == (p1 <= p2)); assert((p1 < p2) == !(p1 >= p2)); } { const std::unique_ptr > p1(new A); const std::unique_ptr > p2(new B); assert((p1 < p2) == !(p1 > p2)); assert((p1 < p2) == (p1 <= p2)); assert((p1 < p2) == !(p1 >= p2)); } { const std::unique_ptr > p1(new A[3]); const std::unique_ptr > p2(new A[3]); assert((p1 < p2) == !(p1 > p2)); assert((p1 < p2) == (p1 <= p2)); assert((p1 < p2) == !(p1 >= p2)); } { const std::unique_ptr > p1(new A[3]); const std::unique_ptr > p2(new B[3]); assert((p1 < p2) == !(p1 > p2)); assert((p1 < p2) == (p1 <= p2)); assert((p1 < p2) == !(p1 >= p2)); } { const std::unique_ptr > p1; const std::unique_ptr > p2; assert((p1 < p2) == (p1 > p2)); assert((p1 < p2) == !(p1 <= p2)); assert((p1 < p2) == !(p1 >= p2)); } { const std::unique_ptr > p1; const std::unique_ptr > p2; assert((p1 < p2) == (p1 > p2)); assert((p1 < p2) == !(p1 <= p2)); assert((p1 < p2) == !(p1 >= p2)); } return 0; }