]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2018-2023 Free Software Foundation, Inc. |
e1821582 JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
18 | // { dg-do run { target c++11 } } | |
19 | ||
20 | #include <utility> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | void | |
24 | test01() | |
25 | { | |
26 | typedef std::pair<int&, int> pair_type; | |
27 | int i = 1; | |
28 | int j = 2; | |
29 | pair_type p(i, 3); | |
30 | const pair_type q(j, 4); | |
31 | p = q; | |
32 | VERIFY( p.first == q.first ); | |
33 | VERIFY( p.second == q.second ); | |
34 | VERIFY( i == j ); | |
35 | } | |
36 | ||
37 | void | |
38 | test02() | |
39 | { | |
40 | typedef std::pair<int, int&> pair_type; | |
41 | int i = 1; | |
42 | int j = 2; | |
43 | pair_type p(3, i); | |
44 | const pair_type q(4, j); | |
45 | p = q; | |
46 | VERIFY( p.first == q.first ); | |
47 | VERIFY( p.second == q.second ); | |
48 | VERIFY( i == j ); | |
49 | } | |
50 | ||
51 | void | |
52 | test03() | |
53 | { | |
54 | typedef std::pair<int&, int&> pair_type; | |
55 | int i = 1; | |
56 | int j = 2; | |
57 | int k = 3; | |
58 | int l = 4; | |
59 | pair_type p(i, j); | |
60 | const pair_type q(k, l); | |
61 | p = q; | |
62 | VERIFY( p.first == q.first ); | |
63 | VERIFY( p.second == q.second ); | |
64 | VERIFY( i == k ); | |
65 | VERIFY( j == l ); | |
66 | } | |
67 | ||
68 | int | |
69 | main() | |
70 | { | |
71 | test01(); | |
72 | test02(); | |
73 | test03(); | |
74 | } |