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// void swap(pair& p);
15
16#include <utility>
17#include <cassert>
18
19struct S {
20    int i;
21    S() : i(0) {}
22    S(int j) : i(j) {}
23    S * operator& () { assert(false); return this; }
24    S const * operator& () const { assert(false); return this; }
25    bool operator==(int x) const { return i == x; }
26    };
27
28int main()
29{
30    {
31        typedef std::pair<int, short> P1;
32        P1 p1(3, static_cast<short>(4));
33        P1 p2(5, static_cast<short>(6));
34        p1.swap(p2);
35        assert(p1.first == 5);
36        assert(p1.second == 6);
37        assert(p2.first == 3);
38        assert(p2.second == 4);
39    }
40    {
41        typedef std::pair<int, S> P1;
42        P1 p1(3, S(4));
43        P1 p2(5, S(6));
44        p1.swap(p2);
45        assert(p1.first == 5);
46        assert(p1.second == 6);
47        assert(p2.first == 3);
48        assert(p2.second == 4);
49    }
50}
51