]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
10 | #include <type_traits> | |
11 | namespace hana = boost::hana; | |
12 | ||
13 | ||
14 | int main() { | |
15 | { | |
16 | typedef std::pair<int, short> P1; | |
17 | hana::pair<int, short> p1(3, 4); | |
18 | hana::pair<int, short> p2 = p1; | |
19 | BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == 3); | |
20 | BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); | |
21 | } | |
22 | ||
23 | static_assert(std::is_trivially_copy_constructible<hana::pair<int, int>>::value, ""); | |
24 | ||
25 | // make sure it also works constexpr | |
26 | { | |
27 | constexpr hana::pair<int, short> p1(3, 4); | |
28 | constexpr hana::pair<int, short> p2 = p1; | |
29 | static_assert(hana::first(p2) == 3, ""); | |
30 | static_assert(hana::second(p2) == 4, ""); | |
31 | } | |
32 | ||
33 | // Make sure it works across pair types (pair<T, U> -> pair<U, V>) | |
34 | { | |
35 | hana::pair<int, short> p1(3, 4); | |
36 | hana::pair<double, long> p2 = p1; | |
37 | BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == 3); | |
38 | BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); | |
39 | } | |
40 | ||
41 | // And also constexpr across pair types | |
42 | { | |
43 | constexpr hana::pair<int, short> p1(3, 4); | |
44 | constexpr hana::pair<double, long> p2 = p1; | |
45 | static_assert(hana::first(p2) == 3, ""); | |
46 | static_assert(hana::second(p2) == 4, ""); | |
47 | } | |
48 | } |