1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <memory> 11 12 // shared_ptr 13 14 // template <class T, class D> 15 // bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; 16 // template <class T, class D> 17 // bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; 18 // template <class T, class D> 19 // bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; 20 // template <class T, class D> 21 // bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; 22 // template <class T, class D> 23 // bool operator<(const unique_ptr<T, D>& x, nullptr_t) noexcept; 24 // template <class T, class D> 25 // bool operator<(nullptr_t, const unique_ptr<T, D>& y) noexcept; 26 // template <class T, class D> 27 // bool operator<=(const unique_ptr<T, D>& x, nullptr_t) noexcept; 28 // template <class T, class D> 29 // bool operator<=(nullptr_t, const unique_ptr<T, D>& y) noexcept; 30 // template <class T, class D> 31 // bool operator>(const unique_ptr<T, D>& x, nullptr_t) noexcept; 32 // template <class T, class D> 33 // bool operator>(nullptr_t, const unique_ptr<T, D>& y) noexcept; 34 // template <class T, class D> 35 // bool operator>=(const unique_ptr<T, D>& x, nullptr_t) noexcept; 36 // template <class T, class D> 37 // bool operator>=(nullptr_t, const unique_ptr<T, D>& y) noexcept; 38 39 #include <memory> 40 #include <cassert> 41 42 void do_nothing(int*) {} 43 44 int main() 45 { 46 const std::unique_ptr<int> p1(new int(1)); 47 assert(!(p1 == nullptr)); 48 assert(!(nullptr == p1)); 49 assert(!(p1 < nullptr)); 50 assert( (nullptr < p1)); 51 assert(!(p1 <= nullptr)); 52 assert( (nullptr <= p1)); 53 assert( (p1 > nullptr)); 54 assert(!(nullptr > p1)); 55 assert( (p1 >= nullptr)); 56 assert(!(nullptr >= p1)); 57 58 const std::unique_ptr<int> p2; 59 assert( (p2 == nullptr)); 60 assert( (nullptr == p2)); 61 assert(!(p2 < nullptr)); 62 assert(!(nullptr < p2)); 63 assert( (p2 <= nullptr)); 64 assert( (nullptr <= p2)); 65 assert(!(p2 > nullptr)); 66 assert(!(nullptr > p2)); 67 assert( (p2 >= nullptr)); 68 assert( (nullptr >= p2)); 69 } 70