functor.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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. #include <boost/hana/assert.hpp>
  5. #include <boost/hana/functional/placeholder.hpp>
  6. #include <boost/hana/integral_constant.hpp>
  7. #include "matrix/comparable.hpp"
  8. #include "matrix/functor.hpp"
  9. namespace hana = boost::hana;
  10. using namespace cppcon;
  11. int main() {
  12. // transform
  13. {
  14. BOOST_HANA_CONSTEXPR_LAMBDA auto m = matrix(
  15. row(1, hana::int_c<2>, 3),
  16. row(hana::int_c<4>, 5, 6),
  17. row(7, 8, hana::int_c<9>)
  18. );
  19. BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
  20. hana::transform(m, hana::_ + hana::int_c<1>),
  21. matrix(
  22. row(2, hana::int_c<3>, 4),
  23. row(hana::int_c<5>, 6, 7),
  24. row(8, 9, hana::int_c<10>)
  25. )
  26. ));
  27. }
  28. }