]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / utilities / utility / pairs / pairs.pair / const_first_const_second_cxx03.pass.cpp
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:
23     A(int data) : data_(data) {}
24
25     bool operator==(const A& a) const {return data_ == a.data_;}
26 };
27
28 int main()
29 {
30     {
31         typedef std::pair<float, short*> P;
32         P p(3.5f, 0);
33         assert(p.first == 3.5f);
34         assert(p.second == nullptr);
35     }
36     {
37         typedef std::pair<A, int> P;
38         P p(1, 2);
39         assert(p.first == A(1));
40         assert(p.second == 2);
41     }
42 }