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 // UNSUPPORTED: c++98, c++03
10 
11 // <utility>
12 
13 // template <class T1, class T2> struct pair
14 
15 // struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
16 // constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
17 
18 #include <utility>
19 #include <tuple>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 class A
25 {
26     int i_;
27     char c_;
28 public:
29     A(int i, char c) : i_(i), c_(c) {}
30     int get_i() const {return i_;}
31     char get_c() const {return c_;}
32 };
33 
34 class B
35 {
36     double d_;
37     unsigned u1_;
38     unsigned u2_;
39 public:
40     B(double d, unsigned u1, unsigned u2) : d_(d), u1_(u1), u2_(u2) {}
41     double get_d() const {return d_;}
42     unsigned get_u1() const {return u1_;}
43     unsigned get_u2() const {return u2_;}
44 };
45 
46 int main(int, char**)
47 {
48     std::pair<A, B> p(std::piecewise_construct,
49                       std::make_tuple(4, 'a'),
50                       std::make_tuple(3.5, 6u, 2u));
51     assert(p.first.get_i() == 4);
52     assert(p.first.get_c() == 'a');
53     assert(p.second.get_d() == 3.5);
54     assert(p.second.get_u1() == 6u);
55     assert(p.second.get_u2() == 2u);
56 
57   return 0;
58 }
59