Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / example / cppcon_2014 / functor.cpp
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/functional/placeholder.hpp>
7 #include <boost/hana/integral_constant.hpp>
8
9 #include "matrix/comparable.hpp"
10 #include "matrix/functor.hpp"
11 namespace hana = boost::hana;
12 using namespace cppcon;
13
14
15 int main() {
16     // transform
17     {
18         auto m = matrix(
19             row(1,              hana::int_c<2>, 3),
20             row(hana::int_c<4>, 5,              6),
21             row(7,              8,              hana::int_c<9>)
22         );
23
24         BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
25             hana::transform(m, hana::_ + hana::int_c<1>),
26             matrix(
27                 row(2,              hana::int_c<3>, 4),
28                 row(hana::int_c<5>, 6,              7),
29                 row(8,              9,              hana::int_c<10>)
30             )
31         ));
32     }
33 }