functor.hpp 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. #ifndef BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_FUNCTOR_HPP
  5. #define BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_FUNCTOR_HPP
  6. #include "matrix.hpp"
  7. #include <boost/hana/functional/flip.hpp>
  8. #include <boost/hana/functional/partial.hpp>
  9. #include <boost/hana/concept/functor.hpp>
  10. #include <utility>
  11. namespace boost { namespace hana {
  12. template <unsigned Rows, unsigned Columns>
  13. struct transform_impl<cppcon::Matrix<Rows, Columns>> {
  14. template <typename M, typename F>
  15. static constexpr decltype(auto) apply(M&& m, F&& f) {
  16. return unpack(
  17. transform(
  18. cppcon::rows(std::forward<M>(m)),
  19. partial(flip(transform), std::forward<F>(f))
  20. ),
  21. cppcon::matrix
  22. );
  23. }
  24. };
  25. }}
  26. #endif // !BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_FUNCTOR_HPP