adjust.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*!
  2. @file
  3. Forward declares `boost::hana::adjust`.
  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_ADJUST_HPP
  9. #define BOOST_HANA_FWD_ADJUST_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Apply a function on all the elements of a structure that compare
  14. //! equal to some value.
  15. //! @ingroup group-Functor
  16. //!
  17. //!
  18. //! Signature
  19. //! ---------
  20. //! Given `F` a Functor and `U` a type that can be compared with `T`'s,
  21. //! the signature is
  22. //! \f$
  23. //! \mathtt{adjust} : F(T) \times U \times (T \to T) \to F(T)
  24. //! \f$
  25. //!
  26. //! @param xs
  27. //! The structure to adjust with `f`.
  28. //!
  29. //! @param value
  30. //! An object that is compared with each element `x` of the structure.
  31. //! Elements of the structure that compare equal to `value` are adjusted
  32. //! with the `f` function.
  33. //!
  34. //! @param f
  35. //! A function called as `f(x)` on the element(s) of the structure that
  36. //! compare equal to `value`.
  37. //!
  38. //!
  39. //! Example
  40. //! -------
  41. //! @include example/adjust.cpp
  42. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  43. constexpr auto adjust = [](auto&& xs, auto&& value, auto&& f) {
  44. return tag-dispatched;
  45. };
  46. #else
  47. template <typename Xs, typename = void>
  48. struct adjust_impl : adjust_impl<Xs, when<true>> { };
  49. struct adjust_t {
  50. template <typename Xs, typename Value, typename F>
  51. constexpr auto operator()(Xs&& xs, Value&& value, F&& f) const;
  52. };
  53. constexpr adjust_t adjust{};
  54. #endif
  55. BOOST_HANA_NAMESPACE_END
  56. #endif // !BOOST_HANA_FWD_ADJUST_HPP