//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 "../deleter.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&) {++count;} virtual ~B() {--count;} }; int B::count = 0; int main() { { 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)); } }