]>
git.proxmox.com Git - ceph.git/blob - 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)
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
;
14 explicit constexpr NoDefault(int) { }
18 DefaultOnly() = default;
19 DefaultOnly(DefaultOnly
const&) = delete;
20 DefaultOnly(DefaultOnly
&&) = delete;
23 struct NonConstexprDefault
{
24 NonConstexprDefault() { }
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);
34 // make sure it also works constexpr
36 constexpr hana::pair
<float, short*> p
;
37 static_assert(hana::first(p
) == 0.0f
, "");
38 static_assert(hana::second(p
) == nullptr, "");
41 // make sure the default constructor is not instantiated when the
42 // members of the pair are not default-constructible
44 hana::pair
<NoDefault
, NoDefault
> p
{NoDefault
{1}, NoDefault
{2}};
48 // make sure it works when only the default constructor is defined
50 hana::pair
<DefaultOnly
, DefaultOnly
> p
;
55 hana::pair
<NonConstexprDefault
, NonConstexprDefault
> p
;