1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <utility>
10
11// template <class T1, class T2> struct pair
12
13// template <class T1, class T2, class U1, class U2> bool operator==(const pair<T1,T2>&, const pair<U1,U2>&);
14// template <class T1, class T2, class U1, class U2> bool operator!=(const pair<T1,T2>&, const pair<U1,U2>&);
15// template <class T1, class T2, class U1, class U2> bool operator< (const pair<T1,T2>&, const pair<U1,U2>&);
16// template <class T1, class T2, class U1, class U2> bool operator> (const pair<T1,T2>&, const pair<U1,U2>&);
17// template <class T1, class T2, class U1, class U2> bool operator>=(const pair<T1,T2>&, const pair<U1,U2>&);
18// template <class T1, class T2, class U1, class U2> bool operator<=(const pair<T1,T2>&, const pair<U1,U2>&);
19
20#include <utility>
21#include <cassert>
22
23#include "test_macros.h"
24
25int main(int, char**)
26{
27 {
28 typedef std::pair<int, short> P1;
29 typedef std::pair<long, long> P2;
30 P1 p1(3, static_cast<short>(4));
31 P2 p2(3, 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(3, 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(2, static_cast<short>(4));
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>(2));
64 P p2(3, 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(2, static_cast<short>(4));
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 typedef std::pair<int, short> P;
85 P p1(3, static_cast<short>(4));
86 P p2(3, static_cast<short>(2));
87 assert(!(p1 == p2));
88 assert( (p1 != p2));
89 assert(!(p1 < p2));
90 assert(!(p1 <= p2));
91 assert( (p1 > p2));
92 assert( (p1 >= p2));
93 }
94
95#if TEST_STD_VER > 11
96 {
97 typedef std::pair<int, short> P;
98 constexpr P p1(3, static_cast<short>(4));
99 constexpr P p2(3, static_cast<short>(2));
100 static_assert(!(p1 == p2), "");
101 static_assert( (p1 != p2), "");
102 static_assert(!(p1 < p2), "");
103 static_assert(!(p1 <= p2), "");
104 static_assert( (p1 > p2), "");
105 static_assert( (p1 >= p2), "");
106 }
107#endif
108
109 return 0;
110}
111

source code of libcxx/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp