]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/pair/make.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/core/make.hpp>
7 #include <boost/hana/first.hpp>
8 #include <boost/hana/pair.hpp>
9 #include <boost/hana/second.hpp>
10 namespace hana
= boost::hana
;
15 MoveOnly(MoveOnly
const&) = delete;
16 MoveOnly
& operator=(MoveOnly
const&) = delete;
17 MoveOnly(int data
) : data_(data
) { }
18 MoveOnly(MoveOnly
&& x
) : data_(x
.data_
) { x
.data_
= 0; }
20 MoveOnly
& operator=(MoveOnly
&& x
)
21 { data_
= x
.data_
; x
.data_
= 0; return *this; }
23 bool operator==(const MoveOnly
& x
) const { return data_
== x
.data_
; }
28 hana::pair
<int, short> p
= hana::make_pair(3, 4);
29 BOOST_HANA_RUNTIME_CHECK(hana::first(p
) == 3);
30 BOOST_HANA_RUNTIME_CHECK(hana::second(p
) == 4);
34 hana::pair
<MoveOnly
, short> p
= hana::make_pair(MoveOnly
{3}, 4);
35 BOOST_HANA_RUNTIME_CHECK(hana::first(p
) == MoveOnly
{3});
36 BOOST_HANA_RUNTIME_CHECK(hana::second(p
) == 4);
40 hana::pair
<MoveOnly
, short> p
= hana::make_pair(3, 4);
41 BOOST_HANA_RUNTIME_CHECK(hana::first(p
) == MoveOnly
{3});
42 BOOST_HANA_RUNTIME_CHECK(hana::second(p
) == 4);
46 constexpr hana::pair
<int, short> p
= hana::make_pair(3, 4);
47 static_assert(hana::first(p
) == 3, "");
48 static_assert(hana::second(p
) == 4, "");
51 // equivalence with make<pair_tag>
53 constexpr hana::pair
<int, short> p
= hana::make
<hana::pair_tag
>(3, 4);
54 static_assert(hana::first(p
) == 3, "");
55 static_assert(hana::second(p
) == 4, "");