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/first.hpp>
6 #include <boost/hana/functional/on.hpp>
7 #include <boost/hana/integral_constant.hpp>
8 #include <boost/hana/less.hpp>
9 #include <boost/hana/pair.hpp>
10 #include <boost/hana/plus.hpp>
11 #include <boost/hana/sort.hpp>
12 #include <boost/hana/tuple.hpp>
13 #include <boost/hana/type.hpp>
14 namespace hana = boost::hana;
15
16
17 // infix application
18 constexpr auto sorted = hana::sort.by(hana::less ^hana::on^ hana::first, hana::make_tuple(
19 hana::make_pair(hana::int_c<3>, 'x'),
20 hana::make_pair(hana::int_c<1>, hana::type_c<void>),
21 hana::make_pair(hana::int_c<2>, 9876)
22 ));
23
24 static_assert(sorted == hana::make_tuple(
25 hana::make_pair(hana::int_c<1>, hana::type_c<void>),
26 hana::make_pair(hana::int_c<2>, 9876),
27 hana::make_pair(hana::int_c<3>, 'x')
28 ), "");
29
30
31 // function call syntax
32 constexpr auto x = hana::make_pair(1, 2);
33 constexpr auto y = hana::make_pair(10, 20);
34 static_assert(hana::on(hana::plus, hana::first)(x, y) == 1 + 10, "");
35
main()36 int main() { }
37