reverse_fold.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*!
  2. @file
  3. Defines `boost::hana::reverse_fold`.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_REVERSE_FOLD_HPP
  9. #define BOOST_HANA_REVERSE_FOLD_HPP
  10. #include <boost/hana/fwd/reverse_fold.hpp>
  11. #include <boost/hana/config.hpp>
  12. #include <boost/hana/fold_right.hpp>
  13. #include <boost/hana/functional/flip.hpp>
  14. BOOST_HANA_NAMESPACE_BEGIN
  15. //! @cond
  16. template <typename Xs, typename S, typename F>
  17. constexpr decltype(auto) reverse_fold_t::operator()(Xs&& xs, S&& s, F&& f) const {
  18. return hana::fold_right(static_cast<Xs&&>(xs),
  19. static_cast<S&&>(s),
  20. hana::flip(static_cast<F&&>(f)));
  21. }
  22. template <typename Xs, typename F>
  23. constexpr decltype(auto) reverse_fold_t::operator()(Xs&& xs, F&& f) const {
  24. return hana::fold_right(static_cast<Xs&&>(xs),
  25. hana::flip(static_cast<F&&>(f)));
  26. }
  27. //! @endcond
  28. BOOST_HANA_NAMESPACE_END
  29. #endif // !BOOST_HANA_REVERSE_FOLD_HPP