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 // <utility> 11 12 // template <class T1, class T2> struct pair 13 14 // template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); 15 // template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); 16 // template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); 17 // template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); 18 // template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); 19 // template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); 20 21 #include <utility> 22 #include <cassert> 23 24 #include "test_macros.h" 25 26 int main() 27 { 28 { 29 typedef std::pair<int, short> P; 30 P p1(3, static_cast<short>(4)); 31 P p2(3, static_cast<short>(4)); 32 assert( (p1 == p2)); 33 assert(!(p1 != p2)); 34 assert(!(p1 < p2)); 35 assert( (p1 <= p2)); 36 assert(!(p1 > p2)); 37 assert( (p1 >= p2)); 38 } 39 { 40 typedef std::pair<int, short> P; 41 P p1(2, static_cast<short>(4)); 42 P p2(3, static_cast<short>(4)); 43 assert(!(p1 == p2)); 44 assert( (p1 != p2)); 45 assert( (p1 < p2)); 46 assert( (p1 <= p2)); 47 assert(!(p1 > p2)); 48 assert(!(p1 >= p2)); 49 } 50 { 51 typedef std::pair<int, short> P; 52 P p1(3, static_cast<short>(2)); 53 P p2(3, static_cast<short>(4)); 54 assert(!(p1 == p2)); 55 assert( (p1 != p2)); 56 assert( (p1 < p2)); 57 assert( (p1 <= p2)); 58 assert(!(p1 > p2)); 59 assert(!(p1 >= p2)); 60 } 61 { 62 typedef std::pair<int, short> P; 63 P p1(3, static_cast<short>(4)); 64 P p2(2, static_cast<short>(4)); 65 assert(!(p1 == p2)); 66 assert( (p1 != p2)); 67 assert(!(p1 < p2)); 68 assert(!(p1 <= p2)); 69 assert( (p1 > p2)); 70 assert( (p1 >= p2)); 71 } 72 { 73 typedef std::pair<int, short> P; 74 P p1(3, static_cast<short>(4)); 75 P p2(3, static_cast<short>(2)); 76 assert(!(p1 == p2)); 77 assert( (p1 != p2)); 78 assert(!(p1 < p2)); 79 assert(!(p1 <= p2)); 80 assert( (p1 > p2)); 81 assert( (p1 >= p2)); 82 } 83 84 #if TEST_STD_VER > 11 85 { 86 typedef std::pair<int, short> P; 87 constexpr P p1(3, static_cast<short>(4)); 88 constexpr P p2(3, static_cast<short>(2)); 89 static_assert(!(p1 == p2), ""); 90 static_assert( (p1 != p2), ""); 91 static_assert(!(p1 < p2), ""); 92 static_assert(!(p1 <= p2), ""); 93 static_assert( (p1 > p2), ""); 94 static_assert( (p1 >= p2), ""); 95 } 96 #endif 97 } 98