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 // pair(const T1& x, const T2& y);
15
16 #include <utility>
17 #include <cassert>
18
19 class A
20 {
21 int data_;
22 public:
A(int data)23 A(int data) : data_(data) {}
24
operator ==(const A & a) const25 bool operator==(const A& a) const {return data_ == a.data_;}
26 };
27
28 #if _LIBCPP_STD_VER > 11
29 class AC
30 {
31 int data_;
32 public:
AC(int data)33 constexpr AC(int data) : data_(data) {}
34
operator ==(const AC & a) const35 constexpr bool operator==(const AC& a) const {return data_ == a.data_;}
36 };
37 #endif
38
main()39 int main()
40 {
41 {
42 typedef std::pair<float, short*> P;
43 P p(3.5f, 0);
44 assert(p.first == 3.5f);
45 assert(p.second == nullptr);
46 }
47 {
48 typedef std::pair<A, int> P;
49 P p(1, 2);
50 assert(p.first == A(1));
51 assert(p.second == 2);
52 }
53
54 #if _LIBCPP_STD_VER > 11
55 {
56 typedef std::pair<float, short*> P;
57 constexpr P p(3.5f, 0);
58 static_assert(p.first == 3.5f, "");
59 static_assert(p.second == nullptr, "");
60 }
61 {
62 typedef std::pair<AC, int> P;
63 constexpr P p(1, 2);
64 static_assert(p.first == AC(1), "");
65 static_assert(p.second == 2, "");
66 }
67 #endif
68 }
69