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