[Support] Recycler: Match dealloc size and enforce min size (#121889)
[llvm-project.git] / libcxx / test / std / utilities / utility / pairs / pair.piecewise / piecewise_construct.pass.cpp
blob65f6d62ec09a34d8cbb70c54a2daaa26a9c1094c
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 // <utility>
13 // template <class T1, class T2> struct pair
15 // struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
16 // constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
18 #include <utility>
19 #include <tuple>
20 #include <cassert>
22 #include "test_macros.h"
24 class A
26 int i_;
27 char c_;
28 public:
29 constexpr A(int i, char c) : i_(i), c_(c) {}
30 constexpr int get_i() const {return i_;}
31 constexpr char get_c() const {return c_;}
34 class B
36 double d_;
37 unsigned u1_;
38 unsigned u2_;
39 public:
40 constexpr explicit B(double d, unsigned u1, unsigned u2) : d_(d), u1_(u1), u2_(u2) {}
41 constexpr double get_d() const {return d_;}
42 constexpr unsigned get_u1() const {return u1_;}
43 constexpr unsigned get_u2() const {return u2_;}
46 TEST_CONSTEXPR_CXX20
47 bool test()
49 std::pair<A, B> p(std::piecewise_construct,
50 std::make_tuple(4, 'a'),
51 std::make_tuple(3.5, 6u, 2u));
52 assert(p.first.get_i() == 4);
53 assert(p.first.get_c() == 'a');
54 assert(p.second.get_d() == 3.5);
55 assert(p.second.get_u1() == 6u);
56 assert(p.second.get_u2() == 2u);
58 return true;
61 int main(int, char**)
63 test();
64 #if TEST_STD_VER >= 20
65 static_assert(test());
66 #endif
68 return 0;