1//===----------------------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9// <utility>
10
11// template <class T1, class T2> struct pair
12
13// pair(const T1& x, const T2& y);
14
15#include <utility>
16#include <cassert>
17
18#include "test_macros.h"
19
20class A
21{
22 int data_;
23public:
24 A(int data) : data_(data) {}
25
26 bool operator==(const A& a) const {return data_ == a.data_;}
27};
28
29int main(int, char**)
30{
31 {
32 typedef std::pair<float, short*> P;
33 P p(3.5f, 0);
34 assert(p.first == 3.5f);
35 assert(p.second == nullptr);
36 }
37 {
38 typedef std::pair<A, int> P;
39 P p(1, 2);
40 assert(p.first == A(1));
41 assert(p.second == 2);
42 }
43
44 return 0;
45}
46

source code of libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.const_first_const_second_cxx03.pass.cpp