| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::fuse`. |
| 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_FWD_FUSE_HPP |
| 11 | #define BOOST_HANA_FWD_FUSE_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | |
| 15 | |
| 16 | namespace boost { namespace hana { |
| 17 | //! Transform a function taking multiple arguments into a function that |
| 18 | //! can be called with a compile-time `Foldable`. |
| 19 | //! @ingroup group-Foldable |
| 20 | //! |
| 21 | //! |
| 22 | //! This function is provided for convenience as a different way of |
| 23 | //! calling `unpack`. Specifically, `fuse(f)` is a function such that |
| 24 | //! @code |
| 25 | //! fuse(f)(foldable) == unpack(foldable, f) |
| 26 | //! == f(x...) |
| 27 | //! @endcode |
| 28 | //! where `x...` are the elements in the foldable. This function is |
| 29 | //! useful when one wants to create a function that accepts a foldable |
| 30 | //! which is not known yet. |
| 31 | //! |
| 32 | //! @note |
| 33 | //! This function is not tag-dispatched; customize `unpack` instead. |
| 34 | //! |
| 35 | //! |
| 36 | //! Example |
| 37 | //! ------- |
| 38 | //! @include example/fuse.cpp |
| 39 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 40 | constexpr auto fuse = [](auto&& f) { |
| 41 | return [perfect-capture](auto&& xs) -> decltype(auto) { |
| 42 | return unpack(forwarded(xs), forwarded(f)); |
| 43 | }; |
| 44 | }; |
| 45 | #else |
| 46 | struct fuse_t { |
| 47 | template <typename F> |
| 48 | constexpr auto operator()(F&& f) const; |
| 49 | }; |
| 50 | |
| 51 | BOOST_HANA_INLINE_VARIABLE constexpr fuse_t fuse{}; |
| 52 | #endif |
| 53 | }} // end namespace boost::hana |
| 54 | |
| 55 | #endif // !BOOST_HANA_FWD_FUSE_HPP |
| 56 | |