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 // struct piecewise_construct_t { };
15 // constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
16 
17 #include <utility>
18 #include <tuple>
19 #include <cassert>
20 
21 class A
22 {
23     int i_;
24     char c_;
25 public:
A(int i,char c)26     A(int i, char c) : i_(i), c_(c) {}
get_i() const27     int get_i() const {return i_;}
get_c() const28     char get_c() const {return c_;}
29 };
30 
31 class B
32 {
33     double d_;
34     unsigned u1_;
35     unsigned u2_;
36 public:
B(double d,unsigned u1,unsigned u2)37     B(double d, unsigned u1, unsigned u2) : d_(d), u1_(u1), u2_(u2) {}
get_d() const38     double get_d() const {return d_;}
get_u1() const39     unsigned get_u1() const {return u1_;}
get_u2() const40     unsigned get_u2() const {return u2_;}
41 };
42 
main()43 int main()
44 {
45 #ifndef _LIBCPP_HAS_NO_VARIADICS
46     std::pair<A, B> p(std::piecewise_construct,
47                       std::make_tuple(4, 'a'),
48                       std::make_tuple(3.5, 6u, 2u));
49     assert(p.first.get_i() == 4);
50     assert(p.first.get_c() == 'a');
51     assert(p.second.get_d() == 3.5);
52     assert(p.second.get_u1() == 6u);
53     assert(p.second.get_u2() == 2u);
54 #endif
55 }
56