]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/pair/cnstr.default.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / pair / cnstr.default.cpp
1 // Copyright Louis Dionne 2013-2016
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/first.hpp>
7 #include <boost/hana/pair.hpp>
8 #include <boost/hana/second.hpp>
9 namespace hana = boost::hana;
10
11
12 struct NoDefault {
13 NoDefault() = delete;
14 explicit constexpr NoDefault(int) { }
15 };
16
17 struct DefaultOnly {
18 DefaultOnly() = default;
19 DefaultOnly(DefaultOnly const&) = delete;
20 DefaultOnly(DefaultOnly&&) = delete;
21 };
22
23 struct NonConstexprDefault {
24 NonConstexprDefault() { }
25 };
26
27 int main() {
28 {
29 hana::pair<float, short*> p;
30 BOOST_HANA_RUNTIME_CHECK(hana::first(p) == 0.0f);
31 BOOST_HANA_RUNTIME_CHECK(hana::second(p) == nullptr);
32 }
33
34 // make sure it also works constexpr
35 {
36 constexpr hana::pair<float, short*> p;
37 static_assert(hana::first(p) == 0.0f, "");
38 static_assert(hana::second(p) == nullptr, "");
39 }
40
41 // make sure the default constructor is not instantiated when the
42 // members of the pair are not default-constructible
43 {
44 hana::pair<NoDefault, NoDefault> p{NoDefault{1}, NoDefault{2}};
45 (void)p;
46 }
47
48 // make sure it works when only the default constructor is defined
49 {
50 hana::pair<DefaultOnly, DefaultOnly> p;
51 (void)p;
52 }
53
54 {
55 hana::pair<NonConstexprDefault, NonConstexprDefault> p;
56 (void)p;
57 }
58 }