1 // Copyright Louis Dionne 2013-2017
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/config.hpp>
7 #include <boost/hana/first.hpp>
8 #include <boost/hana/pair.hpp>
9 #include <boost/hana/second.hpp>
10 namespace hana = boost::hana;
11
12
in_constexpr_context(int a,short b)13 constexpr auto in_constexpr_context(int a, short b) {
14 hana::pair<int, short> p1(a, b);
15 hana::pair<int, short> p2;
16 hana::pair<double, long> p3;
17 p2 = p1;
18 p3 = p2;
19 return p3;
20 }
21
main()22 int main() {
23 {
24 hana::pair<int, short> p1(3, 4);
25 hana::pair<double, long> p2;
26 p2 = p1;
27 BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == 3);
28 BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4);
29 }
30
31 // make sure that also works in a constexpr context
32 // (test fails under GCC <= 6 due to buggy constexpr)
33 #if BOOST_HANA_CONFIG_GCC >= BOOST_HANA_CONFIG_VERSION(7, 0, 0)
34 {
35 constexpr auto p = in_constexpr_context(3, 4);
36 static_assert(hana::first(p) == 3, "");
37 static_assert(hana::second(p) == 4, "");
38 }
39 #endif
40 }
41