1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class T1, class T2> struct pair
13 // void swap(pair& p);
18 #include "test_macros.h"
22 TEST_CONSTEXPR_CXX20
S() : i(0) {}
23 TEST_CONSTEXPR_CXX20
S(int j
) : i(j
) {}
24 TEST_CONSTEXPR_CXX20
bool operator==(int x
) const { return i
== x
; }
27 TEST_CONSTEXPR_CXX20
bool test() {
29 typedef std::pair
<int, short> P1
;
30 P1
p1(3, static_cast<short>(4));
31 P1
p2(5, static_cast<short>(6));
33 assert(p1
.first
== 5);
34 assert(p1
.second
== 6);
35 assert(p2
.first
== 3);
36 assert(p2
.second
== 4);
39 typedef std::pair
<int, S
> P1
;
43 assert(p1
.first
== 5);
44 assert(p1
.second
== 6);
45 assert(p2
.first
== 3);
46 assert(p2
.second
== 4);
51 int main(int, char**) {
53 #if TEST_STD_VER >= 20
54 static_assert(test());