transform.hpp 1.4 KB

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