| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::transform`. |
| 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_TRANSFORM_HPP |
| 11 | #define BOOST_HANA_FWD_TRANSFORM_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/core/when.hpp> |
| 15 | |
| 16 | |
| 17 | namespace boost { namespace hana { |
| 18 | //! Map a function over a `Functor`. |
| 19 | //! @ingroup group-Functor |
| 20 | //! |
| 21 | //! |
| 22 | //! Signature |
| 23 | //! --------- |
| 24 | //! Given `F` a Functor, the signature is |
| 25 | //! \f$ |
| 26 | //! \mathtt{transform} : F(T) \times (T \to U) \to F(U) |
| 27 | //! \f$ |
| 28 | //! |
| 29 | //! @param xs |
| 30 | //! The structure to map `f` over. |
| 31 | //! |
| 32 | //! @param f |
| 33 | //! A function called as `f(x)` on element(s) `x` of the structure, |
| 34 | //! and returning a new value to replace `x` in the structure. |
| 35 | //! |
| 36 | //! |
| 37 | //! Example |
| 38 | //! ------- |
| 39 | //! @include example/transform.cpp |
| 40 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 41 | constexpr auto transform = [](auto&& xs, auto&& f) { |
| 42 | return tag-dispatched; |
| 43 | }; |
| 44 | #else |
| 45 | template <typename Xs, typename = void> |
| 46 | struct transform_impl : transform_impl<Xs, when<true>> { }; |
| 47 | |
| 48 | struct transform_t { |
| 49 | template <typename Xs, typename F> |
| 50 | constexpr auto operator()(Xs&& xs, F&& f) const; |
| 51 | }; |
| 52 | |
| 53 | BOOST_HANA_INLINE_VARIABLE constexpr transform_t transform{}; |
| 54 | #endif |
| 55 | }} // end namespace boost::hana |
| 56 | |
| 57 | #endif // !BOOST_HANA_FWD_TRANSFORM_HPP |
| 58 | |