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